;
function setPosition(position) {
    $('.navbar .nav > li').each(function (index) {
        var liObj = $('a', $(this)).eq(0);
        if (liObj.text().indexOf(position) > -1) {
            liObj.addClass('active');
            return false;
        }

        var liObj = $('span', $(this)).eq(0);
        if (liObj.text().indexOf(position) > -1) {
            liObj.addClass('active');
            return false;
        }
    });
}
// 导航高亮(阿涛) 
function setNav(txt) {
    $('.nav li').each(function () {
        var obj = $.extend({}, $(this).children('a').eq(0), $(this).children('span').eq(0));
        if (obj.text().indexOf(txt) > -1) {
            $(this).addClass('active');
        }
    });
}

// 侧栏导航高亮(阿涛)
function setSiteNav(txt) {
    $('.site-nav li').each(function () {
        var obj = $.extend({}, $(this).children('a').eq(0), $(this).children('span').eq(0));
        if (obj.text().indexOf(txt) > -1) {
            $(this).addClass('active');
        }
    });
}

// 判断是否已登录
$(function () {
    $(".js_upload_btn").on("click",function(){
        if (!objSite.isLogin()) {
            // 如果没有验证打开登录窗口
            openLogin();
            return false;
        }
    });
});

String.prototype.myTrim = function () {
    return this.replace(/^\s*|\s*$/g, '')
}

var objSite = objSite || {};
//消息提示
objSite.msg = function (msg, icon) {
    if (typeof (icon) == 'undefined') {
        icon = 1;
    }
    layer.msg(msg, {
        icon: icon,
        time: 1000
    });
};

//提问消息
objSite.confirm = function (msg, callBack) {
    layer.confirm(msg, callBack);
};

//警告提示
objSite.alert = function (msg, icon) {
    if (typeof (icon) == 'undefined') {
        icon = 5;
    }
    layer.alert(msg, {
        icon: icon,
        time: 1000
    });
};

//格式化URL
objSite.formatUrl = function (url, domainUrl) {
    if (url == "") {
        return "";
    }
    if (url.substring(0, 4) == 'http') {
        return url;
    }

    if (url.substring(0, 5) == 'https') {
        return url;
    }

    if (url.substring(0, 1) == '/') {
        url = url.substring(1, url.length);
    }
    return domainUrl + url;

};
//获取用户站点URl
objSite.getUserUrl = function (url) {
    return objSite.formatUrl(url, objSite.user_domain);
};

//获取主站站点URl
objSite.getWwwUrl = function (url) {
    return objSite.formatUrl(url, objSite.index_domain);
};

//获取商城站点URl
objSite.getShopUrl = function (url) {
    return objSite.formatUrl(url, objSite.shop_domain);
};
//获取新商城站点URl
objSite.getMallUrl = function (url) {
    return objSite.formatUrl(url, objSite.mall_domain);
};

//获取服务站点URl
objSite.getServiceUrl = function (url) {
    return objSite.formatUrl(url, objSite.service_domain);
};

//获取搜索站点URl
objSite.getSoUrl = function (url) {
    return objSite.formatUrl(url, objSite.so_domain);
};

//获取api站点URl
objSite.getApiUrl = function (url) {
    return objSite.formatUrl(url, objSite.api_domain);
};

//获取静态站点URl
objSite.getStaticUrl = function (url) {
    return objSite.formatUrl(url, objSite.static_domain);
};

//获取溜云库官网站点URl
objSite.getKuUrl = function (url) {
    return objSite.formatUrl(url, objSite.ku_domain);
};

//获取图片站点URl
objSite.getPicUrl = function (url) {
    return objSite.formatUrl(url, objSite.pic_domain);
};

//获取下载站点URl
objSite.getDownUrl = function (url) {
    return objSite.formatUrl(url, objSite.down_domain);
};

//获取小图站点URl
objSite.getImgUrl = function (url) {
    return objSite.formatUrl(url, objSite.img_domain);
};

//获取vip站点URL
objSite.getVipUrl = function (url) {
    return objSite.formatUrl(url, objSite.vip_domain);
};

// 获取xuanran站点URL
objSite.getXuanranUrl = function (url) {
    return objSite.formatUrl(url, objSite.xuanran_domain);
};

//获取mss站点URL
objSite.getMssUrl = function (url) {
    return objSite.formatUrl(url, objSite.magic_domain);
};

//获取溜云库站点URL
objSite.getManagerUrl = function (url) {
    return objSite.formatUrl(url, objSite.manager_domain);
};

//获取溜云库站点URL
objSite.getVrUrl = function (url) {
    return objSite.formatUrl(url, objSite.vr_domain);
};

//获取上传站点URL
objSite.getUploadUrl = function (url) {
    return objSite.formatUrl(url, objSite.upload_file_domain);
};

//获取库站点URL
objSite.getKuUrl = function (url) {
    return objSite.formatUrl(url, objSite.ku_domain);
};

//获取工作室站点URL
objSite.getWorkUrl = function (url) {
    return objSite.formatUrl(url, objSite.work_domain);
};

//获取充值链接URl
objSite.getLbPayUrl = function (url) {
    return objSite.formatUrl(url, objSite.pay_link);
};

//获取充值链接URl
objSite.getZixueUrl = function (url) {
    return objSite.formatUrl(url, objSite.zixue_domain);
};

//获取ip站点URl
objSite.getIpUrl = function (url) {
    return objSite.formatUrl(url, objSite.ip_domain);
};

//获取linggantu站点URl
objSite.getLinggantuUrl = function (url) {
    return objSite.formatUrl(url, objSite.linggantu_domain);
};
//获取anli站点URl
objSite.getAnliUrl = function (url) {
    return objSite.formatUrl(url, objSite.anli_domain);
};
//获取xiaoguotu站点URl
objSite.getXiaoguotuUrl = function (url) {
    return objSite.formatUrl(url, objSite.xiaoguotu_domain);
};
//获取3d站点URl
objSite.get3dUrl = function (url) {
    return objSite.formatUrl(url, objSite.d3_domain);
};

//获取su站点URl
objSite.getSuUrl = function (url) {
    return objSite.formatUrl(url, objSite.su_domain);
};

//获取tietu站点URl
objSite.getTietuUrl = function (url) {
    return objSite.formatUrl(url, objSite.tietu_domain);
};

//获取新埋点站点域名URl
objSite.getServiceTrackingUrl = function (url) {
    return objSite.formatUrl(url, objSite.service_tracking);
};

//判断是否验证
objSite.isLogin = function () {
    try {
        var userInfo = $.cookie('userCookieData');
        if (userInfo && userInfo != 'null') {
            return true;
        } else {
            return false;
        }
    } catch (error) {
        console.log(error);
    }
    
};

//活动充值页面模板判断是否验证
objSite.activityIsLogin = function () {
    if ($(".is_login").hasClass("logined")) {
        return true;
    } else {
        return false;
    }
};

// 打开用户页面
objSite.openUserWin = function (url, area, options,cancel) {
    // 此处处理收藏夹弹框
    if(url.match('fav/www_form')){
        var skins = 'layer-nobg-collection';
        // var skins = 'layer-nobg';

    }else{
        var skins = 'layer-nobg';
    }

    // 地址
    url = objSite.getUserUrl(url);
    // 尺寸
    var area = area || ['400px', '500px'];
    // 默认配置
    var defaults = {
        type: 2,
        title: false,
        skin: skins,
        content: [url, 'no'],
        area: area,
        checkLogin: false,
        cancel: cancel
    };

    var options = $.extend(defaults, options);
    // 如果需要检查认证
    if (options.checkLogin) {
        if (!objSite.isLogin()) {
            // 如果没有验证打开登录窗口
            openLogin();
            return false;
        }
    }
    // 标题
    layer.closeAll();
    layer.open(options);
    // // 新增矫正偏移
    var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
    if (is_mobi) {
        var myarea=$(".layui-layer").width();
        $(".layui-layer").css("left","50%");
        $(".layui-layer").css("margin-left",(-myarea)/2);
    }
};


// 打开用户页面
objSite.openDownWin = function (url, area, options,cancel) {
    // 地址
    url = objSite.getUserUrl(url);
    // 尺寸
    var area = area || ['400px', '500px'];
    // 默认配置
    var defaults = {
        type: 2,
        title: false,
        content: [url, 'no'],
        area: area,
        checkLogin: false,
        cancel: cancel
    };

    var options = $.extend(defaults, options);
    // 如果需要检查认证
    if (options.checkLogin) {
        if (!objSite.isLogin()) {
            // 如果没有验证打开登录窗口
            openLogin();
            return false;
        }
    }
    // 标题
    layer.closeAll();
    layer.open(options);
    // // 新增矫正偏移
    var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
    if (is_mobi) {
        var myarea=$(".layui-layer").width();
        $(".layui-layer").css("left","50%");
        $(".layui-layer").css("margin-left",(-myarea)/2);
    }
};
var audio_tbody_options;
function audio_tbody(){
        try {
            var e = d = !1,
            t = "audio_tbody";
            audio_tbody_options = [];
            var n = new AudioContext || new webkitAudioContext;
            var i, o, r = n,
                a = r.createAnalyser(),
                c = r.destination,
                s = {
                    ac: ["state", "sampleRate"],
                    ae: ["maxChannelCount", "numberOfInputs", "numberOfOutputs", "channelCount", "channelCountMode", "channelInterpretation"],
                    az: ["fftSize", "frequencyBinCount", "minDecibels", "maxDecibels", "smoothingTimeConstant"]
                };
            for (o in s){
                for (var l in s[o]){
                    "ac" == o && (i = r), "ae" == o && (i = c), "az" == o && (i = a), s[o][l], i[s[o][l]], t
                    audio_tbody_options += s[o][l]+',';
                } 
            }
            var add = audio_tbody_options.split(',')
        } catch (error) {}
        
}
/* ajaxUser公用函数
   checkLogin 必须认证为true
   */
objSite.ajaxUser = function (url, data, callBack, checkLogin) {
    url = objSite.getUserUrl(url);
    if (url == "") {
        return false;
    }
    //Ajax调用处理
    $.ajax({
        type: "GET",
        crossDomain: true,
        url: url,
        timeout: 10000,
        data: data,
        dataType: 'jsonp',
        jsonp: 'callback',
        error: function (jqXHR, textStatus, errorThrown) {
            switch (textStatus) {
                case "timeout":
                    objSite.alert("加载超时，请重试!");
                    break;
                case "error":
                    objSite.alert("请求异常，请稍后再试!");
                    break;
                default:
                    // objSite.alert(textStatus);
                    break;
            }
        },
        success: function (result) {
            if (objSite.test_model == "1") {
                try {
                    // console.log(result);
                } catch (e) {}
            }
            if (checkLogin == true && result.status == 100) {
                //打开登录窗口
                openLogin();
                return false;
            }
            if (result.status == "1" || result.code == "1") {
                //操作成功
                if (typeof (callBack) != "undefined" && callBack != "") {
                    if (typeof (callBack) == "function") {
                        //执行闭包
                        callBack(result);
                        return false;
                    } else if (callBack == "reload") {
                        //刷新页面
                        //提示返回信息
                        if (result.msg != "") {
                            objSite.msg(result.msg, 1);
                        }
                        setTimeout(function () {
                            objSite.ajaxReloadPage();
                        }, 1000);
                    } else {
                        setTimeout(function () {
                            objSite.msg(result.msg, 1);
                            objSite.ajaxGoPage(callBack);
                        }, 1000);
                    }
                } else {
                    //提示返回信息
                    if (result.msg != "") {
                        objSite.msg(result.msg, 1);
                    }
                }

            } else {
                callBack(result);
                return false;
            }
        }
    });
}

var userzo2 = ''; 
// audio_tbody();
// 统一调用：/login/index/userinfo
try{
    for (var b in navigator.userAgentData) {
        userzo2 += b + " ";
    }
    userzo2 = userzo2 || "null";
    objSite.ajaxUser('/login/index/userInfo', { vbnm:userzo2 }, function (res) {
        sessionStorage.setItem('userInfoData',JSON.stringify(res));

        if(!$.cookie('isNewUser')){ 
            var endDate = new Date();
            endDate.setDate(endDate.getDate()+1);
            endDate.setHours(0);
            endDate.setMinutes(0);
            endDate.setSeconds(0);
            $.cookie("isNewUser",res.data.user_id,{
                expires: endDate,
                domain: '3d66.com',
                path: '/'
            });
            newRegisterUser();
        }else{
            if($.cookie('isNewUser') != res.data.user_id){ //更新当前userID
                var endDate = new Date();
                endDate.setDate(endDate.getDate()+1);
                endDate.setHours(0);
                endDate.setMinutes(0);
                endDate.setSeconds(0);
                $.cookie("isNewUser",res.data.user_id,{
                    expires: endDate,
                    domain: '3d66.com',
                    path: '/'
                });
                newRegisterUser();
            }
        }

        if(res.data.activity_ab){
            $(".activities_switch_tu").css("display","inline-block");
            $(".year2022_icon_1").css("display","block");
            $(".year2022_icon_2").css("display","block");
            $(".ll-9th-year").css("display","block");
        }else{
            $(".activities_switch_text").css("display","inline-block");
            $(".year2022_icon_1").css("display","none");
            $(".year2022_icon_2").css("display","none");
            $(".global-pay .new-rechage-pay .user-type-info").css("background","");
            $(".ll-9th-year").css("display","none");
        }

        if(res.status == 10099){
            llFuncGo();
            return false;
        }
        if(res.status==1){
            // 上传用户接单广告位需求
            // try{
            //     $.cookie('user_upload_task', res.data.user_upload_task, { expires: 7 });
            //     if(res.data.user_upload_task!=1){
            //         $('.user-left-focus[data-id="561"]').remove();
            //     }
            // }catch (error) {
            //     console.log('err:',error)
            // } 
            
            // 上传活动埋点参数
            var integrityurl = window.location.href;
            var pointFlag='';
            if( //列表
                integrityurl.indexOf('com/model')!=-1
                ||integrityurl.indexOf('com/sketchup')!=-1
                ||integrityurl.indexOf('com/material')!=-1
                ||integrityurl.indexOf('com/tietu')!=-1
                ||integrityurl.indexOf('com/album')!=-1
                ||integrityurl.indexOf('com/light')!=-1
                ||integrityurl.indexOf('com/maxscript')!=-1
                ){
                pointFlag='60';
            }else if(integrityurl.indexOf('/reshtml/model')!=-1){ //详情
                pointFlag='62';
                 // VIP重复下载永久免费权益内测
                // if(res.data.vip_active_status==1||res.data.vip_active_status==2){
                //     $('.recharge-discount>a.discount-btn').append('<span class="vip-permanent-dow"></span>');
                // }
            }else if(integrityurl.indexOf('/res/')!=-1){ //搜索
                pointFlag='61';
            }else{//其他页面
                pointFlag='63';
            }
            // VIP重复下载永久免费权益内测
            if(res.data.vip_active_status==1){
               $('.js_RightNewvipBox .subnav-vip-content').remove();
            }else{
                $('.js_RightNewvipBox .vip-repeat-download-activity').remove(); 
            }
             // 上传活动判断
            //  上传用户问卷调研 
                if(res.data.user_is_upload==1){
                    $('.subnav-upload-activity,.js_upload_btn_cc .icon-nav-free').remove(); 
                    $('.subnav-upload-old').remove();
                    $('.subnav-upload-old,.subnav-upload-share').remove(); 
                    $('.upload-top-investigation>a.link-investigation').attr('data-id',res.data.user_id);
                    $('.right-top-act[data-id="350"]').removeClass('sysFocusImgSing focus66').html('<em class="close-icon"></em><a class="js_link_investigation" data-id="'+res.data.user_id+'" data-type="index-float"><img src="'+objSite.getStaticUrl("/www2/images/act-right.png")+'" alt=""></a>');
                    $('.www-fluid-container .sysFocusTextImage>li').eq(3).html('<a class="focusUrl js_link_investigation" data-id="'+res.data.user_id+'" data-type="index-ad"><span class="round-bg"><img src="https://img.3d66.com/focus/2022/20220412/1353255dfbf72c8775c6ca72789c1937.png" alt=""></span><p class="text-area"><span class="title">上传作者问卷调研</span><span class="desc">2分钟参与调研立得50提现币</span></p></a>')
                    $('.indexfoucs-rightb .sysFocusImgSing[data-id="412"]').html('<a class="js_link_investigation" data-id="'+res.data.user_id+'" data-type="sidebar"><img src="'+objSite.getStaticUrl("/www2/images/right-investigation.png")+'" alt=""></a>')
                }else if(res.data.new_upload_status==1){//老用户
                    // 新用户弹窗
                    $('.subnav-upload-activity,.js_upload_btn_cc .icon-nav-free').remove(); 
                    // // 未登录下拉
                    $('.subnav-upload-old,.upload-top-investigation').remove();
                    $('.subnav-upload-share>a.share-link').attr('href',objSite.getUserUrl("/share_relation?e="+pointFlag)); 
                    // www首页个人广告位
                    if($('.new-user-upload').find('.sysFocusImgSing').attr('data-id')=='528'){
                        $('.subnav-upload-share>a.share-link').attr('href',objSite.getUploadUrl("/share_relation?e=59")); 
                        $('.new-user-upload').html('<div class="product-img-link js_upload_btn"><a rel="nofollow" href="'+objSite.getUploadUrl("/share_relation?e=67")+'" target="_blank"><img src="'+objSite.getStaticUrl("/user/images/upload-model/share/new-upload.jpg")+'" alt=""></a></div>');
                    }  
                    $('.right-top-act a').attr('href','https://www.3d66.com/ad/index_detail?id=6376&url=https://user.3d66.com/share_relation%3De=67&image=https://img.3d66.com/focus/2022/20220222/70e6e1e13e6e0e0884effb2f4fa8b39c.png');
                    $('.right-top-act a img').attr('src','https://img.3d66.com/focus/2022/20220222/70e6e1e13e6e0e0884effb2f4fa8b39c.png');
                } else if(res.data.new_upload_status==2){ //  老带新被邀请用户
                    $('.subnav-upload-activity').parent().find('a.nav-link').attr('href',objSite.getUploadUrl("/upload/index/index?point="+pointFlag));  
                    $('.subnav-upload-activity .model-publishing').attr('href',objSite.getUploadUrl("/upload/index/index?point="+pointFlag));
                    $('.js_upload_btn_cc .icon-nav-free').show();
                    $('.subnav-upload-old,.subnav-upload-share,.upload-top-investigation').remove(); 
                    // $('.ad-list-focus[data-id="620"] a').eq(1).attr('href','https://www.3d66.com/ad/index_detail?id=6528&url=https://upload_file.3d66.com/upload/index/index%3De=64&image=https://img.3d66.com/focus/2022/20220221/f8035efea575eb06a07e48a3abc8e36f.png');
                    // $('.ad-list-focus[data-id="620"] a').eq(1).find('img').attr('src',objSite.getStaticUrl("/user/images/upload-model/new-user-index.png"));
                    // www首页个人广告位
                    if($('.new-user-upload').find('.sysFocusImgSing').attr('data-id')=='528'){
                        $('.subnav-upload-activity').parent().find('a.nav-link').attr('href',objSite.getUploadUrl("/upload/index/index?point=59"));  
                        $('.subnav-upload-activity .model-publishing').attr('href',objSite.getUploadUrl("/upload/index/index?point=59"));
                        // $('.new-user-upload').html('<div class="product-img-link js_upload_btn"><a rel="nofollow" href="'+objSite.getUploadUrl("/upload/index/index?point=64")+'" target="_blank"><img src="'+objSite.getStaticUrl("/user/images/upload-model/new-upload.png")+'" alt=""></a></div>');
                    }
                }else{//    新用户没被邀请
                        // 新用户下拉
                    $('.subnav-upload-activity,.js_upload_btn_cc .icon-nav-free').remove(); 
                    // 老用户下拉
                    $('.subnav-upload-share').remove();
                    // 上传用户问卷调研
                    $('.upload-top-investigation').remove();
                }

                // 上传任务奖励活动弹窗
                if(res.data.activity_upload_is==1 && res.data.is_upload_act){
                    $('.right-top-act[data-id="350"]').removeClass('sysFocusImgSing focus66').html('<em class="close-icon"></em><a class="js_activity_rewards" data-id="'+res.data.user_id+'" data-type="index-float"><img src="'+objSite.getStaticUrl("/www2/images/act/top-popup.png")+'" alt=""></a>');
                    try{
                        if($.cookie('activity_upload_is')!='1'){
                            $('.js_activity_rewards').click();
                            $.cookie('activity_upload_is', 1, { expires: 1 });
                        }
                    }catch (error) {
                        console.log('err:',error)
                    } 
                }  
            if($('.right-top-act a').length!=0){
               
                $(".right-top-act").css("display","block");

                $(window).scroll(function () {
                    if ($(document).scrollTop() >= 200) {  
                        $(".right-top-act").fadeOut(200);
                    } else {
                        $(".right-top-act").fadeIn(200);
                    }
                });
                $('.right-top-act .close-icon').on('click',function(e){
                    $('.right-top-act').hide();
                });
                
                //判断是否有广告位 
                var hasImgLength = $( ".right-top-act:has(img)" ).length;
                if(hasImgLength > 0){
                    $('.right-top-act .close-icon').show();
                }else{
                    $('.right-top-act .close-icon').hide();
                }
            }
        }else{
            // 新用户下拉
            $('.subnav-upload-activity,.js_upload_btn_cc .icon-nav-free').remove(); 
            // 老用户下拉
            $('.subnav-upload-share').remove();
             // 上传用户问卷调研
             $('.upload-top-investigation').remove();
            //  VIP重复下载永久免费权益内测
            $('.js_RightNewvipBox .vip-repeat-download-activity').remove();
        }
    })
} catch (error) {
    console.log('err:',error)
} 
$(document).on('click', '.subnav-upload-activity', function () {
    window.location.href=objSite.getUploadUrl("/upload/index/index?tab=1");
});
$(document).on('click', '.subnav-upload-activity a', function (event) {
    event.stopPropagation()
});

// 判断是否新用户注册
function newRegisterUser(){
    $.ajax({
        type: "GET",
        crossDomain: true,
        url: objSite.getServiceUrl('/api/v1/NewUserVipAct/trigger'),
        timeout: 10000,
        dataType: 'jsonp',
        jsonp: 'callback',
        xhrFields: {
            withCredentials: true // 这里设置了withCredentials
        },
        success: function (res) {
            if(res.status == 1){
                if(res.data.is_dialog){
                    if(res.data.activity_type == 1){ //七天vip试用
                        layer.open({
                            type: 1,
                            closeBtn:1,
                            title:'',
                            skin: 'layer-nobg', //加上边框
                            area: ['482px', '587px'], //宽高
                            content: '<div class="register-user"><a href="'+ objSite.getVipUrl('/') +'" target="_blank"></a></div>'
                        });
                    }else if(res.data.activity_type == 2){ // vip季卡
                        layer.open({
                            type: 1,
                            closeBtn:1,
                            title:'',
                            skin: 'layer-nobg', //加上边框
                            area: ['650px', '467px'], //宽高
                            content: '<div class="quarter-user"><a data-id="25" class="js_open_vipPopup" href="javascript:void(0);"></a></div>'
                        });
                    }else if(res.data.activity_type == 3){ // 付费模型下载
                        layer.open({
                            type: 2,
                            skin: 'layer-nobg',
                            title: false,
                            resize: false,
                            area: ['850px', '596px'],
                            content: objSite.getServiceUrl('/pay/down_model'),
                        });
                    }
                }
            }                
        },
    })
};


// 上传任务奖励活动弹窗
$(document).on('click', '.js_activity_rewards,.js_activity_upload', function () {
    $.ajax({
        type: "get",
        url:objSite.getServiceUrl( "/api/v1/Act202207/getCommon"),
        data: "data",
        dataType: "jsonp",
        success: function (res) {
            if(res.status==1){
                var state=res.data.activity_info;
                if(state.month_info.is_reward==0){
                    var weekProgressWidth=0;
                    if(state.week_num==1){
                        weekProgressWidth=15;
                    }else if(state.week_num==2){
                        weekProgressWidth=33;
                    }else if(state.week_num==3){
                        weekProgressWidth=60;
                    }else if(state.week_num==4){
                        weekProgressWidth=100;
                    }
                    var totle='>'+state.week_info.week_num;
                    if(state.week_info.extra_num>0){
                        totle=state.week_info.extra_num;
                    }
                    
                    var weekLbsEl = "";
                    var resNumEl = ""
                    weekLbsEl +='<div class="act-award">[周任务奖励]：</div>';
                    weekLbsEl +='<p>每周上传任务包括基础任务和进阶任务，完成基础任务即可完成当周任务；每周活动时间为周一00:00~周日24:00；</p>';
                    if(state.group == 1){
                        weekLbsEl +='<p>周基础任务：成功发布<em class="txt">'+ state.week_info.week_num +'个</em>模型即完成周基础任务，同时得<em class="txt">'+ state.week_info.week_reward_lb +'提现币</em>奖励；</p>';
                        resNumEl = '总奖励<em class="sum-total">'+state.week_info.week_reward_lb +'</em>提现币';
                    }else{
                        weekLbsEl +='<p>周基础任务：成功发布<em class="txt txt1">'+ state.week_info.week_num +'个</em>模型即完成周基础任务，每发布<em class="txt">1个</em>模型奖励<em class="txt">'+ state.week_info.week_reward_lb +'提现币</em>；</p>';
                        resNumEl = '每个模型奖励<em class="sum-total">'+state.week_info.week_reward_lb+'</em>提现币';
                    }
                    weekLbsEl +='<p>周进阶任务：当发布模型数量<em class="txt">＞'+ state.week_info.week_num +'个</em>时，每多发布<em class="txt">1个</em>模型奖励<em class="txt">'+ state.week_info.week_extra_reward_lb +'提现币</em>；</p>';
                    weekLbsEl +='<p>每周任务进度统计时间以<em class="txt">作品通过审核完成发布</em>为准，起始时间为周一00:00，结束时间为周日24:00；</p>';
                    weekLbsEl +='<p><span class="zy">注意：</span>每周发布模型量超过500个以上则不计入奖励；</p>';
                    weekLbsEl +='<div class="act-award act-award-last">[月任务奖励]：</div>';
                    weekLbsEl +='<p>完成<em class="txt">4周基础任务</em>的前提下，即可参与领取月任务奖励；</p>';
                    weekLbsEl +='<p>根据月度发布量可获得不同奖励，每月奖励仅可领取一档、不可重复叠加领取；</p>';

                    var openInvestigation='<div class="layer-activity-rewards">'+
                    '<div class="activity-rules">'+
                        '<span class="rule">活动规则</span>'+
                        '<div class="act-rules">'+ weekLbsEl +'</div>'+
                    '</div>'+
                    '<div class="clearfix modle-tle">'+
                        '<p>'+resNumEl+'</p>'+
                        '<p>每个模型奖励<em class="sum-num">'+ state.week_info.week_extra_reward_lb +'</em>提现币</p>'+
                    '</div>'+
                    '<div class="clearfix model-release">'+
                        '<p>模型发布量：'+state.week_info.res_num+'/'+state.week_info.week_num+'</p>'+
                        '<p>模型发布量：'+totle+'</p>'+
                    '</div>'+
                    '<div class="clearfix modle-hint">'+
                        '<p><i>*</i>完成基础任务即可完成本周任务</p>'+
                        '<p><i>*</i>每发布一个模型奖励<em>'+ state.week_info.week_extra_reward_lb +'</em>提现币</p>'+
                    '</div>'+
                    '<div class="clearfix be-conduct">'+
                        '<div class="bar-progress">'+
                            '<p style="width:'+weekProgressWidth+'%"></p>'+
                        '</div>'+
                        '<div class="be-item-list first-item">'+
                            '<p class="'+weekStatusList(state.week_info.status_list.week_status_1,'class')+'">'+weekStatusList(state.week_info.status_list.week_status_1)+'</p><span>第1周</span>'+
                        '</div>'+
                        '<div class="be-item-list">'+
                            '<p class="'+weekStatusList(state.week_info.status_list.week_status_2,'class')+'">'+weekStatusList(state.week_info.status_list.week_status_2)+'</p><span>第2周</span>'+
                        '</div>'+
                        '<div class="be-item-list">'+
                            '<p class="'+weekStatusList(state.week_info.status_list.week_status_3,'class')+'">'+weekStatusList(state.week_info.status_list.week_status_3)+'</p><span>第3周</span>'+
                        '</div>'+
                        '<div class="be-item-list">'+
                            '<p class="'+weekStatusList(state.week_info.status_list.week_status_4,'class')+'">'+weekStatusList(state.week_info.status_list.week_status_4)+'</p><span>第4周</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix be-conduct task-monthly">'+
                        '<div class="bar-progress">'+
                            '<p></p>'+
                        '</div>'+
                        '<div class="be-item-list first-item">'+
                            '<p class="'+weekStatusList(state.month_info.status_list.month_status_1,'class')+'">'+weekStatusList(state.month_info.status_list.month_status_1)+'</p><span>月发布量'+state.month_info.status_num.month_num_1+'/'+state.month_info.status_num.month_num_1_success+'</span>'+
                        '</div>'+
                        '<div class="be-item-list">'+
                            '<p class="'+weekStatusList(state.month_info.status_list.month_status_2,'class')+'">'+weekStatusList(state.month_info.status_list.month_status_2)+'</p><span>月发布量'+state.month_info.status_num.month_num_2+'/'+state.month_info.status_num.month_num_2_success+'</span>'+
                        '</div>'+
                        '<div class="be-item-list">'+
                            '<p class="'+weekStatusList(state.month_info.status_list.month_status_3,'class')+'">'+weekStatusList(state.month_info.status_list.month_status_3)+'</p><span>月发布量'+state.month_info.status_num.month_num_3+'/'+state.month_info.status_num.month_num_3_success+'</span>'+
                        '</div>'+
                    '</div>'+
                    '<a class="task-upload-href" href="https://upload_file.3d66.com/upload/index/index"></a>'+
                    '</div>';
                    layer.open({
                        type: 1,
                        closeBtn:1,
                        title:'',
                        skin: 'layer-nobg', //加上边框
                        area: ['560px', '656px'], //宽高
                        content:openInvestigation
                    });
                }else{
                    var openInvestigation='';
                    // vip
                    if(state.month_info.reward_grade==1){
                        openInvestigation='<div class="all-vip-rewards"><a class="layer-popup-ques-close" data-id="'+state.month_info.activity_upload_id+'"></a></div>'
                    }else if(state.month_info.reward_grade==2){
                        openInvestigation='<div class="kit-charger-rewards"><a href="'+objSite.getUserUrl("/account/address/index")+'" data-id="'+state.month_info.activity_upload_id+'" target="_blank"></a></div>'
                    }else if(state.month_info.reward_grade==3){
                        openInvestigation='<div class="box-music-rewards"><a href="'+objSite.getUserUrl("/account/address/index")+'" data-id="'+state.month_info.activity_upload_id+'" target="_blank"></a></div>'
                    }
                    layer.open({
                        type: 1,
                        closeBtn:1,
                        title:'',
                        skin: 'layer-nobg', //加上边框
                        area: ['500px', '500px'], //宽高
                        content:openInvestigation
                    });
                }
            }
        }
    });
});
function weekStatusList(type,cls){
    if(cls==='class'){
        if(type==2){
            return 'have-in-hand'
        }else if(type==3){
            return 'up-to-standard'
        }
    }
    if(type==1){
        return '待开始'
    }else if(type==2){
        return '进行中'
    }else if(type==3){
        return '已达标'
    }else if(type==4){
        return '未达标'
    }
}
// 填写地址埋点
$(document).on('click','.box-music-rewards a,.kit-charger-rewards a,.layer-popup-ques-close',function(){
    var rewardId=$(this).attr('data-id');
    $.ajax({
        type: "get",
        url:objSite.getServiceUrl( "/api/v1/Act202207/writeAddress"),
        data: {activity_upload_id:rewardId},
        dataType: "jsonp",
        success: function (res) {

        }
    });
});
// 上传用户问卷调研
$(document).on('click', '.upload-top-investigation>a.link-investigation,.js_link_investigation', function () {
    var type="";
    if($(this).attr('data-type')){
        type=$(this).attr('data-type');
    }else{
        type='navigate-upload';
    }
    var openInvestigation='<div class="layer-popup-investigation"><i class="layer-popup-ques-close"></i><p class="questionnaire_user_id">您的溜溜ID：'+$(this).attr('data-id')+'</p><a target="_blank" href="https://www.wjx.cn/vj/Pw7QcQv.aspx" data-type="'+type+'" class="js-fill-now">立即填写></a></div>';
    layer.open({
        type: 1,
        closeBtn:0,
        title:'',
        skin: 'layer-nobg', //加上边框
        area: ['400px', '300px'], //宽高
        content:openInvestigation
    });
});
$(document).on('click','.js-fill-now',function(){
    objSite.ajaxUser('/active/Investigate/record', { position:$(this).attr('data-type')}, function (res) {});
});

// 注册弹窗
function openRegister() {
    layer.closeAll();
    objSite.openUserWin('/login/popover/register', ['998px', '498px']);
}

$(document).on('click', '.j_user-reg,.j_register', function () {
    openRegister();
});

// VIP重复下载永久免费权益内测
function freeDowPermanent(type){
    var FreeHtml='<div class="popup-free-download-permanent">'+
                    '<div class="vip-rule">'+
                    '<p></p>'+
                    '</div>'+
                    '<a class="vip-operation goto-open" data-vip_type="1" data-repeat="'+type+'"></a>'+
                '</div>';
    layer.open({
        type: 1,
        // closeBtn:0,
        title:'',
        skin: 'layer-nobg', //加上边框
        area: ['644px', '612px'], //宽高
        content:FreeHtml
    });
}


// 登录弹窗
openLogin = function () {
    var seoNews='';
    var hrefWind=window.location.href;
    if($('.seo-new-people').length!=0||((hrefWind.indexOf('/relation/')!=-1||hrefWind.indexOf('/sketchup_relation/')!=-1||hrefWind.indexOf('/tietu_relation/')!=-1)&&hrefWind.indexOf('rlai=')!=-1)){
        seoNews='?reg_refer=relation';
    }
    var seoPageSite = "";
    if($.cookie("is_seo_promotion") == "1"){
        // 是否是推广页过来 注册位置(0：seo页面  ，1：主站)
       var pageview_site = parent.$("#seo_page").val();//0：素材_relation 1:溜溜文章，2：自学文章，3：溜溜问答，4：课程，5：溜云库站点
       var sign = seoNews ? "&" : "?";
       if(pageview_site || pageview_site == 0){
            seoPageSite= sign + "pageview_site=" + pageview_site +"&registration_site=0";
        }else{
            seoPageSite= sign + "registration_site=1";
        }
   }
    objSite.openUserWin('/login/popover/welcome'+seoNews+seoPageSite, ['998px', '498px']);
};
$(document).on('click', '.j_user-login,.juser-login', function () {
    openLogin();
});

// 找回密码弹窗
function openFindback() {
    try {
        layer.closeAll();
    } catch (e) {}
    objSite.openUserWin('/login/forget_pass', ['400px', '450px']);
}

$(document).on('click', '.j_findback', function () {
    openFindback();
});

// 跳转我的订单列表
function jumpOrderList() {
    //如果需要检查认证
    if (!objSite.isLogin()) {
        //如果没有验证打开登录窗口
        openLogin();
        return false;
    } else {
        window.location.href = '/order.html';
    }
}



// 下载弹窗
function openDownload(ll_id, pay_type,actid, searchActionId, sotuActionId, kw, res_type, rlai, collect, dl_course, data_first,st) {
    res_type = res_type || 0;
    if(typeof data_first ==="undefined"){
        data_first = "0";
    }

    //先去判断是否登录
    objSite.ajaxUser('/login/index/userInfo', {}, function (res) {
        if (res.status == 1) {
            // var url = '/download/down?ll_id=' + ll_id + '&action_id=' + searchActionId + '&sotuActionId='
            //     + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&collect=' + collect + '&dl_course=' + dl_course;
            // if ((res_type == 1 || res_type == 6 ) && res.data.is_work  > 0 ) {
            //     objSite.openDownWin(url, ['460px', '370px'], { skin: 'recharge-submit',shadeClose:true }, function () {
            //         var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
            //         var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
            //         if (html == '立即充值') {
            //             addCoupon(2, 14);
            //         }
            //     });
            // } else if ((res_type == 1 || res_type == 6 ) && res.data.is_work  < 1 ) {
            //     objSite.openDownWin(url, ['460px', '335px'], { skin: 'recharge-submit',shadeClose:true }, function () {
            //         var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
            //         var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
            //         if (html == '立即充值') {
            //             addCoupon(2, 14);
            //         }
            //     });
            // } else{
            //     objSite.openDownWin(url, ['350px', '204px'], { title: '下载信息', }, function () {
            //         var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
            //         var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
            //         if (html == '立即充值') {
            //             addCoupon(2, 14);
            //         }
            //     });
            // }
            // return false;
            if (pay_type == 3) {
                if (res_type == 5) {
                    objSite.openUserWin('/download/www_vip_form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&collect=' + collect + '&dl_course=' + dl_course + '&first=' + data_first + '&st=' + st, ['860px', '370px'], {
                        "skin": "layer-mclose"
                    }, function () {
                        try {
                            // 材质增长埋点关闭
                            var getPreset = sessionStorage.getItem('preset');
                            if(getPreset){
                                getPreset = JSON.parse(getPreset)
                                // console.log('getPreset:',getPreset)
                                if(res_type == 2){
                                    getPreset.report_time = Math.floor(new Date().getTime() / 1000);
                                    getPreset.buried_base_type ='web_dowload_vip_content_click';
                                    getPreset.details_page_vip_btn_content = 2;
                                    $.ajax({
                                        url: objSite.getServiceUrl('/record/record/navClickRecord'),
                                        type: 'post',
                                        data: getPreset,
                                        xhrFields: {
                                            withCredentials: true
                                        },
                                        success: function(res){
                                            if(res.code == 1){
                                                
                                            }
                                        }
                                    })
                                }
                            }
                        } catch (error) {}
                        var $parent = $('.layer-mclose iframe').contents().find("b.download-button");
                        var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                        if (html == '立即充值') {
                            addCoupon(2, 14);
                        }
                    });
                } else if (res_type == 2) {
                    /*判断三天内是否有下载过*/
                    objSite.ajaxUser('/download/Three_Days_Free_Down_Form/materialResCheck', {
                        'll_id': ll_id
                    }, function (data) {
                        if (data.status == 1) {
                            if (data.data.user_is_vip == 1 || data.data.lb_download_method == 0 || data.data.pay_type == 0) {
                                // 跳转VIP免费下载弹窗
                                objSite.openUserWin('/download/www_free_form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&dl_course=' + dl_course + '&st=' + st, ['555px', '370px'], {
                                    "skin": "layer-mclose"
                                }, function () {
                                    var $parent = $('.layer-mclose iframe').contents().find("b.download-button");
                                    var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                                    if (html == '立即充值') {
                                        addCoupon(2, 14);
                                    }
                                });
                            } else {
                                // 跳转VIP收费下载弹窗
                                objSite.openUserWin('/download/www_vip_form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&collect=' + collect + '&dl_course=' + dl_course + '&first=' + data_first + '&st=' + st, ['860px', '370px'], {
                                    "skin": "layer-download2"
                                }, function () {
                                    var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
                                    var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                                    if (html == '立即充值') {
                                        addCoupon(2, 14);
                                    }
                                });
                            }
                        }
                    });
                } else {
                    /*判断三天内是否有下载过*/
                    objSite.ajaxUser('/download/Three_Days_Free_Down_Form/check', {
                        'll_id': ll_id
                    }, function (data) {
                        if (data.status == 1) {
                            objSite.openUserWin('/download/Three_Days_Free_Down_Form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai, ['555px', '405px'], {
                                "skin": "layer-download2"
                            }, function () {
                                var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
                                var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                                if (html == '立即充值') {
                                    addCoupon(2, 14);
                                }
                            });
                        } else {
                            objSite.openUserWin('/download/www_vip_form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&collect=' + collect + '&dl_course=' + dl_course + '&first=' + data_first + '&st=' + st, ['860px', '370px'], {
                                "skin": "layer-download2"
                            }, function () {
                                var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
                                var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                                if (html == '立即充值') {
                                    addCoupon(2, 14);
                                }
                            });
                        }
                    });
                }
            } else if (pay_type == 0 || pay_type == 4) {
                objSite.openUserWin('/download/www_free_form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&collect=' + collect + '&dl_course=' + dl_course + '&st=' + st, ['555px', '370px'], {
                    "skin": "layer-mclose"
                }, function () {
                    var $parent = $('.layer-mclose iframe').contents().find("b.download-button");
                    var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                    if (html == '立即充值') {
                        addCoupon(2, 14);
                    }
                });
            } else {
                /*判断三天内是否有下载过*/
                objSite.ajaxUser('/download/Three_Days_Free_Down_Form/check', {
                    'll_id': ll_id
                }, function (data) {
                    if (data.status == 1) {
                        objSite.openUserWin('/download/Three_Days_Free_Down_Form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai, ['554px', '405px'], {
                            "skin": "layer-download2"
                        }, function () {
                            var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
                            var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                            if (html == '立即充值') {
                                addCoupon(2, 14);
                            }
                        });
                    } else {

                        objSite.openUserWin('/download/www_form?ll_id=' + ll_id +'&actid=' + actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&collect=' + collect + '&dl_course=' + dl_course + '&first=' + data_first + '&st=' + st, ['860px', '370px'], {
                            "skin": "layui-layer-iframe"
                        }, function () {
                            var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
                            var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                            if (html == '立即充值') {
                                addCoupon(2, 14);
                            }
                        });
                    }
                });
            }
        } else {
            openLogin();
            return false;
        }
    });
}

// 新版下载弹窗
function openDownloadNews(ll_id, pay_type,actid, searchActionId, sotuActionId, kw, res_type, rlai, collect, dl_course, data_first,st){
    res_type = res_type || 0;
    if(typeof data_first ==="undefined"){
        data_first = "0";
    }

    var click_res_source = 0;
    //先去判断是否登录
    objSite.ajaxUser('/login/index/userInfo', {}, function (res) {
        if (res.status == 1) {

            $.ajax({
                url:objSite.getUserUrl('/api/v1/download/check'),
                type:'GET',
                dataType: 'json',
                data:{
                    ll_id:ll_id
                },
                xhrFields: {
                    withCredentials: true
                },
                //因为在默认情况下，跨源请求不提供凭据(cookie、HTTP认证及客户端SSL证明等)。通过将withCredentials属性设置为true，可以指定某个请求应该发送凭据。如果服务器接收带凭据的请求，会用下面的HTTP头部来响应。
                success:function(data){

                    if (data.status == 1) {

                        if(data.data.status == 1){
                            objSite.openUserWin('/download/www_free_form?ll_id=' + ll_id +'&actid='+ actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&dl_course=' + dl_course + '&st=' + st, ['555px', '376px'], {
                                "skin": "layer-nobg"
                            }, function () {
                                var $parent = $('.layer-mclose iframe').contents().find("b.download-button");
                                var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                                if (html == '立即充值') {
                                    addCoupon(2, 14);
                                }
                            });
                        }else{
                            objSite.openUserWin('/download/www_form/newIndex?ll_id=' + ll_id +'&actid=' + actid + '&action_id=' + searchActionId + '&sotuActionId=' + sotuActionId + '&kw=' + kw + '&rlai=' + rlai + '&collect=' + collect + '&dl_course=' + dl_course + '&first=' + data_first + '&st=' + st, ['895px', '432px'], {
                                "skin": "layer-nobg"
                            }, function () {
                                var $parent = $('.layer-download2 iframe').contents().find("b.download-button");
                                var html = $parent.parent().is(':hidden') ? '' : $parent.eq(0).text();
                                if (html == '立即充值') {
                                    addCoupon(2, 14);
                                }
                            });
                        }
                        
                    } else {
                        openLogin();
                        return false;
                    }
                },
                error:function(e){
                    console.log(e)
                }
            });
    
        }else {
            openLogin();
            return false;
        }
    });
}


$(document).on('click', '.btn-cancel', function () {
    window.open(objSite.getLbPayUrl("/"));
});

$(document).on('click', '.download-button,.btn-cancel', function () {
    // window.open(objSite.getLbPayUrl("/")+'?e=4');
    window.open(objSite.getServiceUrl("/tollfree2020.html"));
});

// $(document).on('click', '.download-button,.download-company-button', function () {
//     $('.pay-erweima-btn').click();
// });

$(document).on('click', '.download-company-button,.btn-cancel', function () {
    window.open(objSite.getServiceUrl("/buy/company_web"));
});

$(document).on('click', '.j_download', function (event) {
    if($(this).attr("data-checkbutton") != "1"){
        if (!objSite.isLogin()) {
            //如果没有验证打开登录窗口
            openLogin();
            return false;
        }
    }else{
        if($('#actid').get(0)){
            if($('#actid').val() == ''){
                $.ajax({
                    url: objSite.getWwwUrl('/buried/res_detail/downClick'),
                    type: 'post',
                    success: function(res){},
                    error: function(err){
                        console.log('err:',err);
                    }
                })
            }
        }
        event.stopPropagation();
        var searchActionId = $('#searchActionId').val();
        if (typeof (searchActionId) == "undefined") {
            searchActionId = '';
        }
        var sotuActionId = $('#sotuActionId').val();
        if (typeof (sotuActionId) == "undefined") {
            sotuActionId = '';
        }
    
        var searchKeyword = $('#searchKeyword').val();
        if (typeof (searchKeyword) == "undefined" || searchKeyword == 'null') {
            searchKeyword = '';
        }
    
        var rlai = $('#rlai').val();
        if (typeof (rlai) == "undefined") {
            rlai = '';
        }
    
        var collect = $('#collect').val();
        if (typeof (collect) == "undefined") {
            collect = '';
        }
    
        //列表页AB下载埋点
        var dl_course = $(this).attr('dl-course');
        if (typeof (dl_course) == "undefined") {
            dl_course = 0;
        }
    
        var st = $('#st').val();
        if (typeof (st) == "undefined") {
            st = 0;
        }

        var actid = $('#actid').val();
        if (typeof (actid) == "undefined") {
            actid = '';
        }
        
    
        var vip_level = $('.jislogin dl dd span').data('vip_level');
        var www_vip_level = $('#vip_level').val();
        var www_vip_level = 0;
        var ll_id = $(this).attr('data-id') || $('#ll_id').val();
        var pay_type = $(this).attr('data-type');
        var res_type = $(this).attr('data-restype');
        if (!res_type) {
            res_type = $('#res_type').val() || $('#resType').val();
        }
        //1为收费模型，0为免费
        // if (pay_type > 0 && pay_type != 'undefined') {
        //收费模型判断是否登录
        // if (!objSite.isLogin()) {
        //     //如果没有验证打开登录窗口
        //     openLogin();
        //     return false;
        // }
        // }
        
        var data_first = $(this).attr("data-first");

        $.ajax({
            url:objSite.getUserUrl('/api/v1/download/check'),
            type:'GET',
            dataType: 'json',
            data:{
                ll_id:ll_id
            },
            xhrFields: {
                withCredentials: true
            },
            //因为在默认情况下，跨源请求不提供凭据(cookie、HTTP认证及客户端SSL证明等)。通过将withCredentials属性设置为true，可以指定某个请求应该发送凭据。如果服务器接收带凭据的请求，会用下面的HTTP头部来响应。
            success:function(res){
                if (res.status == 1) {
                    if(res.data.is_new == 1){
                        // 新版下载弹窗
                        openDownloadNews(ll_id, pay_type, actid, searchActionId, sotuActionId, searchKeyword, res_type, rlai, collect, dl_course, data_first,st);
                    }else{
                        // 旧版下载弹窗
                        openDownload(ll_id, pay_type, actid, searchActionId, sotuActionId, searchKeyword, res_type, rlai, collect, dl_course, data_first,st);
                    }
                }else {
                    openLogin();
                    return false;
                }
            }
        });

    }

    
});

$(document).on('click', '.j_download_lyk', function () {


    var ll_id = $(this).attr('data-id');
    // var res_type = $(this).data('res_type');
    // if (res_type == 6) {
    //     //素材贵族弹窗
    //     layer.open({
    //         type: 2,
    //         skin: 'layer-nobg',
    //         title: false,
    //         resize: false,
    //         area: ['960px', '600px'],
    //         content: objSite.getServiceUrl('/pay/new_vip_page/index?type=2&cz_channel=14&cz_source=1&activity_id=0')
    //     });
    //     return false;
    // }
    objSite.openUserWin('/download/www_lyk_form?ll_id=' + ll_id, ['480px', '200px'], {
        shade: 0
    });

    try {
        $.ajax({
            url:objSite.getUserUrl('/download/www_lyk_form/log?ll_id=' + ll_id),
            type:'GET',
            dataType: 'json',
            data:{
            },
            success:function(res){
            },
            error:function(e){
                console.log(e)
            }
        }); 
    } catch (error) {
        console.log(error);
    }
    
});
$(document).on('click', '.download-lyk-open ', function () {
    var ll_id = $(this).attr('data-id');
    var web_sys = $(this).attr('data-web-sys');
    objSite.openUserWin('/download/www_lyk_form?ll_id=' + ll_id + '&web_sys=' + web_sys, ['480px', '200px'], {
        shade: 0
    });
});

// 首页上传点击
$(document).on('click', '.jupload', function () {
    if (!objSite.isLogin()) {
        //如果没有验证打开登录窗口
        openLogin();
        return false;
    }
    window.location.href = objSite.getUserUrl('/#/upload/index_form');
});

// 首页充值点击
$(document).on('click', '.jcharge', function () {
    if (!objSite.isLogin()) {
        //如果没有验证打开登录窗口
        openLogin();
        return false;
    }
    window.location.href = objSite.getLbPayUrl("/");
});

// 首页我的消息点击
$(document).on('click', '.jmymsg', function () {
    if (!objSite.isLogin()) {
        //如果没有验证打开登录窗口
        openLogin();
        return false;
    }
    window.location.href = objSite.getUserUrl('/#/msg/index_list');
});

// 首页我的收藏点击
$(document).on('click', '.jmyfav', function () {
    if (!objSite.isLogin()) {
        //如果没有验证打开登录窗口
        openLogin();
        return false;
    }
    window.location.href = objSite.getUserUrl('/#/fav/index_list/index');
});

// 首页我的主页点击
$(document).on('click', '.jmypage', function () {
    if (!objSite.isLogin()) {
        //如果没有验证打开登录窗口
        openLogin();
        return false;
    }
    window.location.href = objSite.getUserUrl('/#/index/index/main');
});

// 收藏弹窗
function openCollect(ll_id) {
    objSite.openUserWin('/fav/www_form?ll_id=' + ll_id, ['600px', '450px'], {
        "title": ['添加到收藏夹','display:none;height:50px;line-height:50px'],
        checkLogin: true,
    });
}

$(document).on('click', '.j_collect', function (event) {
    event.stopPropagation();
    var ll_id = $(this).attr('data-id') || $('#ll_id').val();
    openCollect(ll_id);
});

// 获取当前时间
var mls = '';
objSite.getNowTime = function () {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
        " " + date.getHours() + seperator2 + date.getMinutes() +
        seperator2 + date.getSeconds();
    return currentdate;
};

// 彩蛋弹窗
function openCaidan(assets, width, height) {
    var width = width || 750;
    var height = height || 526
    layer.closeAll();
    layer.open({
        skin: 'layer-nobg',
        type: 2,
        title: false,
        resize: false,
        area: [width + 'px', height + 'px'],
        content: [objSite.getServiceUrl('/sixyear2019/caidan_hit/?assets=' + assets), 'no']
    });
}

// 公钥
var navps;
objSite.csrfToken = function () {
    var pubkey = '-----BEGIN PUBLIC KEY-----';
    pubkey += 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIKHrSGDj+e1bLD1GdIa0idrme';
    pubkey += '108lw0cLVA6LC4NWVKyBpioNvx95K4iDUK2Fb+39cAIm099AKsYPPIEmP6vVbaW0';
    pubkey += '161LSmZAKYe6gflgc+3Mp8bTCPS32P7XInnWo7Nyb2Gc1DRhN4yezIBeQCpVsumK';
    pubkey += 'BXYUPiYfW6dcTghsawIDAQAB';
    pubkey += '-----END PUBLIC KEY-----';

    try{
        var encrypt = new JSEncrypt();
        encrypt.setPublicKey(pubkey);
        var data = {
            t: '3d66login'
        };
        var rsadata = JSON.stringify(data);
        var encryptData = encrypt.encrypt(rsadata);
        return encryptData;
    }
    catch(err){
        console.log('err:',err)
    }
};


objSite.csrfPublicToken = function (action) {
    var pubkey = '-----BEGIN PUBLIC KEY-----';
    pubkey += 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIKHrSGDj+e1bLD1GdIa0idrme';
    pubkey += '108lw0cLVA6LC4NWVKyBpioNvx95K4iDUK2Fb+39cAIm099AKsYPPIEmP6vVbaW0';
    pubkey += '161LSmZAKYe6gflgc+3Mp8bTCPS32P7XInnWo7Nyb2Gc1DRhN4yezIBeQCpVsumK';
    pubkey += 'BXYUPiYfW6dcTghsawIDAQAB';
    pubkey += '-----END PUBLIC KEY-----';
    try{
        var encrypt = new JSEncrypt();
        encrypt.setPublicKey(pubkey);
        var data = action;
        var rsadata = JSON.stringify(data);
        var encryptData = encrypt.encrypt(rsadata);
        return encryptData;
    }
    catch(err){
        console.log('err:',err)
    }

};



// 封装更新cookie方法
objSite.updateCookie = function (userCookieData) {
    var get_cookie_time = $.cookie('get_cookie_time');

    //新增更新cookie到期时间
    if (!get_cookie_time) {
        var timestamp = (Date.parse(new Date()) / 1000) + 12 * 60 * 60;
        $.cookie('get_cookie_time', timestamp, {
            expires: 2,
            path: '/',
            domain: '3d66.com'
        });
    } else {
        var now = Date.parse(new Date()) / 1000;
        //过期重新获取
        if (now >= get_cookie_time) {
            //重新设置过去cookie
            var timestamp = (Date.parse(new Date()) / 1000) + 12 * 60 * 60;
            $.cookie('get_cookie_time', timestamp, {
                expires: 2,
                path: '/',
                domain: '3d66.com'
            });
            //登录请求cookie
            objSite.ajaxUser("/login/index/userinfo", {}, function (res) {
                if (res.status == 1) {
                    //替换user_name的key
                    res.data.user_name = res.data.nick_name;
                    objSite.loginTopHtml(res.data);

                    //设置cookie
                    $.cookie('userCookieData', JSON.stringify(res.data), {
                        expires: 2,
                        path: '/',
                        domain: '3d66.com'
                    });
                    return false;
                } else {
                    objSite.loginOutHtml(res);
                }
            });
        }
    }
    // objSite.ajaxUser("/login/index/userinfo", {}, function (res) {
    var tiems = setInterval(function(){
        var userInfoData = JSON.parse(sessionStorage.getItem('userInfoData'));
        if(userInfoData){
            clearInterval(tiems)
            if (userInfoData.status == 1) {
                                // $('input[id="is_seng_coupon"]').length!=1   防止在充值下载币弹窗中发券
                if ($.inArray(window.location.href, userInfoData.data.addCouponUrl) >= 0&&$('input[id="is_seng_coupon"]').length!=1) {
                    addCoupon(8, 0);
                }
                objSite.loginTopHtml(userInfoData.data);
            }else{
                objSite.loginOutHtml();
            }
        }else{
            clearInterval(tiems)
        }
    },500)

};

// 封装前端手机号码正则
// telAreaCode:区号
objSite.phoneRegular = function (telAreaCode) {
    var regular = /(\+|00)(297|93|244|1264|358|355|376|971|54|374|1684|1268|61|43|994|257|32|229|226|880|359|973|1242|387|590|375|501|1441|591|55|1246|673|975|267|236|1|61|41|56|86|225|237|243|242|682|57|269|238|506|53|5999|61|1345|357|420|49|253|1767|45|1809|1829|1849|213|593|20|291|212|34|372|251|358|679|500|33|298|691|241|44|995|44|233|350|224|590|220|245|240|30|1473|299|502|594|1671|592|852|504|385|509|36|62|44|91|246|353|98|964|354|972|39|1876|44|962|81|76|77|254|996|855|686|1869|82|383|965|856|961|231|218|1758|423|94|266|370|352|371|853|590|212|377|373|261|960|52|692|389|223|356|95|382|976|1670|258|222|1664|596|230|265|60|262|264|687|227|672|234|505|683|31|47|977|674|64|968|92|507|64|51|63|680|675|48|1787|1939|850|351|595|970|689|974|262|40|7|250|966|249|221|65|500|4779|677|232|503|378|252|508|381|211|239|597|421|386|46|268|1721|248|963|1649|235|228|66|992|690|993|670|676|1868|216|90|688|886|255|256|380|598|1|998|3906698|379|1784|58|1284|1340|84|678|681|685|967|27|260|263)(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{4,20}$/;
    if (telAreaCode === '+86') {
        regular = /^1[3-9]{1}[0-9]{9}$/;
    }
    return regular;
};

$(function () {
    try {
        var _0x16cf=['ZW9hcGlfVmVyaWZ5VGhpcw==','YnJvd3Nlcg==','cGx1Z2lucw==','c3BsaXQ=','I1NPVVRVX0RJVg==','dXNlckFnZW50','cmVwbGFjZQ==','Vlp2RWY=','c2FkZXNk','bWF0Y2g=','aW5kZXhPZg==','c2NoZWR1bGluZw==','Mnw1fDZ8MXwwfDN8NA==','YXh4SGI=','ZW9hcGk=','YXBwVmVyc2lvbg==','J3NhZmFyaQ==','RklZWWo=','bGVuZ3Ro','c2FmYXJp','bWFuYWdlZA==','b3Rjak8=','YWN2ZmQ=','Q2hyby0tbWU=','dG9Mb3dlckNhc2U=','UVFCcm93c2Vy','d2ViZHJpdmVy','c2VyaWFs','dmVy','ZmlyZWZveA==','MTAuOC40NDA1LjQwMA==','dXNlckFnZW50RGF0YQ==','Y2hyb21l','aXNNb2JpbGU=','UHdneUM='];(function(_0x2d54ca,_0x16cf0f){var _0x5cf532=function(_0x4ffc0a){while(--_0x4ffc0a){_0x2d54ca['push'](_0x2d54ca['shift']());}};_0x5cf532(++_0x16cf0f);}(_0x16cf,0x122));var _0x5cf5=function(_0x2d54ca,_0x16cf0f){_0x2d54ca=_0x2d54ca-0x0;var _0x5cf532=_0x16cf[_0x2d54ca];if(_0x5cf5['RJmCRv']===undefined){(function(){var _0x5f55a9=function(){var _0x1884c0;try{_0x1884c0=Function('return\x20(function()\x20'+'{}.constructor(\x22return\x20this\x22)(\x20)'+');')();}catch(_0x1780c8){_0x1884c0=window;}return _0x1884c0;};var _0x559826=_0x5f55a9();var _0x47682e='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x559826['atob']||(_0x559826['atob']=function(_0x59aa79){var _0x539373=String(_0x59aa79)['replace'](/=+$/,'');var _0x89ea17='';for(var _0x249306=0x0,_0x4ef297,_0x42e73c,_0x2c9b8f=0x0;_0x42e73c=_0x539373['charAt'](_0x2c9b8f++);~_0x42e73c&&(_0x4ef297=_0x249306%0x4?_0x4ef297*0x40+_0x42e73c:_0x42e73c,_0x249306++%0x4)?_0x89ea17+=String['fromCharCode'](0xff&_0x4ef297>>(-0x2*_0x249306&0x6)):0x0){_0x42e73c=_0x47682e['indexOf'](_0x42e73c);}return _0x89ea17;});}());_0x5cf5['uIzkYc']=function(_0x24461c){var _0xc454b4=atob(_0x24461c);var _0x393ebc=[];for(var _0x2af410=0x0,_0x577236=_0xc454b4['length'];_0x2af410<_0x577236;_0x2af410++){_0x393ebc+='%'+('00'+_0xc454b4['charCodeAt'](_0x2af410)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x393ebc);};_0x5cf5['SQtctv']={};_0x5cf5['RJmCRv']=!![];}var _0x4ffc0a=_0x5cf5['SQtctv'][_0x2d54ca];if(_0x4ffc0a===undefined){_0x5cf532=_0x5cf5['uIzkYc'](_0x5cf532);_0x5cf5['SQtctv'][_0x2d54ca]=_0x5cf532;}else{_0x5cf532=_0x4ffc0a;}return _0x5cf532;};var Sys={};var ua=navigator[_0x5cf5('0x1e')][_0x5cf5('0xe')]();var s;(s=ua[_0x5cf5('0x22')](/msie ([\d.]+)/))?Sys['ie']=s[0x1]:(s=ua[_0x5cf5('0x22')](/firefox\/([\d.]+)/))?Sys[_0x5cf5('0x13')]=s[0x1]:(s=ua[_0x5cf5('0x22')](/chrome\/([\d.]+)/))?Sys[_0x5cf5('0x16')]=s[0x1]:(s=ua['match'](/opera.([\d.]+)/))?Sys['opera']=s[0x1]:(s=ua['match'](/version\/([\d.]+).*safari/))?Sys[_0x5cf5('0x9')]=s[0x1]:0x0;function getBrowserInfo(){var _0x8fc009=_0x5cf5('0x2')[_0x5cf5('0x1c')]('|');var _0x5153ee=0x0;while(!![]){switch(_0x8fc009[_0x5153ee++]){case'0':_0x593f52['browser']=_0x3b4ad0[0x1][_0x5cf5('0x1f')](/version/,_0x5cf5('0x6'));continue;case'1':var _0x3b4ad0=_0x5ca3ee[_0x5cf5('0x22')](_0x460380);continue;case'2':var _0x593f52={};continue;case'3':_0x593f52[_0x5cf5('0x12')]=_0x3b4ad0[0x2];continue;case'4':return _0x593f52;case'5':var _0x5ca3ee=navigator['userAgent']['toLowerCase']();continue;case'6':var _0x460380=/(msie|firefox|chrome|opera|version).*?([\d.]+)/;continue;}break;}}var sys_browser=getBrowserInfo()[_0x5cf5('0x1a')];var sys_ver=getBrowserInfo()['ver'];var g=window[_0x5cf5('0xc')]||window[_0x5cf5('0x21')]||window['sdfsfgsgdf'];var nav_appVersion=navigator[_0x5cf5('0x5')][_0x5cf5('0x0')]('QQBrowser')>-0x1;var nav_plugins=navigator[_0x5cf5('0x1b')][_0x5cf5('0x8')];var nav_lang=navigator['languages'][_0x5cf5('0x8')];for(var i in navigator['languages']){mls+=i+'\x20';}var r=!0x1;for(var o in window){if(_0x5cf5('0x4')===o||_0x5cf5('0x19')===o||'eoapi_extInvok'===o){r=!0x0;break;}}if(r){llFuncGo();}if(g){llFuncGo();}if(r&&navigator[_0x5cf5('0x15')]==undefined&&navigator[_0x5cf5('0x10')]==undefined&&navigator[_0x5cf5('0xa')]==undefined&&navigator[_0x5cf5('0x1')]==undefined&&navigator[_0x5cf5('0x11')]==undefined){llFuncGo();}if(r&&sys_browser==_0x5cf5('0xf')&&sys_ver==_0x5cf5('0x14')){llFuncGo();}if(g&&getBrowserInfo()['browser']==_0x5cf5('0xf')&&getBrowserInfo()[_0x5cf5('0x12')]==_0x5cf5('0x14')){var timer=setInterval(function(){var _0x12ea63={};_0x12ea63[_0x5cf5('0x3')]=_0x5cf5('0x20');_0x12ea63['otcjO']=_0x5cf5('0x7');_0x12ea63['PwgyC']=function(_0x245e83,_0x47a575){return _0x245e83(_0x47a575);};var _0x30fdda=_0x12ea63;if($(_0x5cf5('0x1d'))['length']){if(_0x30fdda[_0x5cf5('0x3')]===_0x30fdda[_0x5cf5('0xb')]){mls+=i+'\x20';}else{llFuncGo();_0x30fdda[_0x5cf5('0x18')](clearInterval,timer);}}else{}},0x7d0);}if(navigator[_0x5cf5('0x5')]['indexOf'](_0x5cf5('0xd'))>-0x1){llFuncGo();}if(CefSharp||new MultiplyResponse()||ExecuteAsync||new MathService()){llFuncGo();}if(r&&sys_browser==_0x5cf5('0xf')&&CefSharp){llFuncGo();}if(r&&sys_browser=='QQBrowser'&&new MultiplyResponse()){llFuncGo();}if(r&&ExecuteAsync&&sys_ver=='10.8.4405.400'){llFuncGo();}if(window[_0x5cf5('0x17')]()&&g){llFuncGo();}
    } catch (error) {
    }
});

// 点击学习软件
$(document).on('click', '.click-soft-count', function () {
    var study_id = $(this).data('study_id');
    var studyUrl = objSite.getZixueUrl('/Index/index/click_study_soft');
    $.ajax({
        type: 'POST',
        dataType: 'json',
        data: {
            study_id: study_id
        },
        url: studyUrl
    })
});

// 获取拼团group_id
function GetGroupId() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}


// 抽奖弹窗
function openLottery(url_type) {
    try {
        var lottery_grayscale_user = sessionStorage.getItem('userInfoData') ? JSON.parse(sessionStorage.getItem('userInfoData')) : '';
        if(lottery_grayscale_user.data.lottery_grayscale_user == 1){
            var href = window.location.href;
            var drawUrl = objSite.getUserUrl('/draw/index/lottery');
            if (href.indexOf('user') > -1) {
                layer.open({
                    skin: 'layer-nobg',
                    type: 2,
                    title: false,
                    resize: false,
                    fixed: false,
                    area: ['640px', '770px'],
                    content: [drawUrl, 'no'],
                    success: function (layero, index) {}
                });
            } else {
                if (!objSite.isLogin()) {
                    //如果没有验证打开登录窗口
                    openLogin();
                    return false;
                }
                layer.open({
                    skin: 'layer-nobg',
                    type: 2,
                    title: false,
                    resize: false,
                    fixed: false,
                    area: ['640px', '770px'],
                    content: [drawUrl, 'no'],
                    success: function (layero, index) {
                    },end: function(index, layero){} 
                });
            }
        }else{
            var href = window.location.href;
            if (href.indexOf('user') > -1) {
                $.post('/user/check_login/index', {}, function (res) {
                    var drawUrl = objSite.getUserUrl('/draw/index/index');
                    layer.open({
                        skin: 'layer-nobg',
                        type: 2,
                        title: false,
                        resize: false,
                        fixed: false,
                        area: ['790px', '800px'],
                        content: [drawUrl, 'no'],
                        success: function (layero, index) {
                            var body = layer.getChildFrame('body', index);
                            var iframeWin = window[layero.find('iframe')[0]['name']];
                            iframeWin.runPrizeList();
                        }
                    });
                });
            } else {
                if (!objSite.isLogin()) {
                    //如果没有验证打开登录窗口
                    openLogin();
                    return false;
                }
                objSite.ajaxUser('/user/check_login/index', {}, function (res) {
                    // 抽奖弹窗
                    var drawUrl = objSite.getUserUrl('/draw/index/index');
                    layer.open({
                        skin: 'layer-nobg',
                        type: 2,
                        title: false,
                        resize: false,
                        fixed: false,
                        area: ['790px', '800px'],
                        content: [drawUrl, 'no'],
                        success: function (layero, index) {
                            var body = layer.getChildFrame('body', index);
                            var iframeWin = window[layero.find('iframe')[0]['name']];
                            if(url_type=="tollfree2020"){
                                iframeWin.$(".rules").hide();
                            }
                            iframeWin.runPrizeList();
                        },end: function(index, layero){ 
                            if(url_type=="tollfree2020"){
                               parent.location.reload();
                            }
                          } 
                    });
                }, 1);
            }
        }
    } catch (error) {}  
}

$(document).on('click', '.js-lottery', function () {
    try {
        var userInfo = sessionStorage.getItem('userInfoData') ? JSON.parse(sessionStorage.getItem('userInfoData')) : '';
        var buried_lottery = 0
        if(window.location.origin+'/' == objSite.getVipUrl('/')){
            buried_lottery = 3
        }else if(window.location.origin+'/' == objSite.getUserUrl('/')){
            if($(this).parents('.common-functions').get(0)){
                buried_lottery = 1
            }else{
                buried_lottery = 2
            }
        }
        var lotteryData = {
            buried_base_type: 'click_lottery_panel',
            view_url: document.URL,
            up_time: Math.floor(new Date().getTime() / 1000),
            usertype_lottery: userInfo.data.user_time_type,
            position_click_lottery: buried_lottery
        }
        // 抽奖埋点
        $.ajax({
            url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
            type: 'post',
            data: lotteryData,
            xhrFields: {
                withCredentials: true
            },
            success: function(res){
            }
        })
    } catch (error) {}
    layer.closeAll();
    openLottery();
});

$(document).on('click', '.js-open-lottery', function () {
    parent.layer.closeAll();
    parent.openLottery();
});

function llFuncGo(){var sha180='<div class="ll_check" style="width: 530px;height: 400px;">'+'<div class="ll_check_links" style="padding-top: 297px;padding-left: 87px;">'+'<ul style="font-size: 0;">'+'<li style="display: inline-block;margin-right: 34px;"><a href="http://browser.360.cn/" target="_0" style="display: block;cursor: pointer;height: 75px;width: 60px;"></a></li>'+'<li style="display: inline-block;margin-right: 34px;"><a href="https://dl.softmgr.qq.com/original/Browser/91.0.4472.77_chrome_installer_32.exe" target="_0" style="display: block;cursor: pointer;height: 75px;width: 60px;"></a></li>'+'<li style="display: inline-block;margin-right: 34px;"><a href="https://browser.qq.com/" target="_0" style="display: block;cursor: pointer;height: 75px;width: 60px;"></a></li>'+'<li style="display: inline-block;margin-right: 34px;"><a href="https://browser.360.cn/ee/" target="_0" style="display: block;cursor: pointer;height: 75px;width: 60px;"></a></li>'+'</ul>'+'</div>'+'</div>';$('body').html('<div class="ll_check_newbg"></div>');layer.open({type:1,title:false,id:'',skin:'layer-nobg',closeBtn:0,area:['530px','400px'],content:sha180,success:function(layero,index){}})}

// 点击抽奖
$(document).on('click', '#popup-gift-btn', function () {
    parent.layer.closeAll();
    parent.openLottery();
});
// 签到新弹窗
function openSignNew(signToken) {
    var href = window.location.href;
    // var load = layer.load(1);

    if ($(".sign").hasClass("signed")) {
        // 当用户已经签到时
        layer.open({
            type: 2, // 1（页面层）2（iframe层）
            title: false,
            id: '', // 弹窗唯一id
            skin: 'layer-nobg', //自定义皮肤类
            closeBtn: '1', //配置1和2来展示，如果不显示，则closeBtn: 0
            area: ['460px', '431px'], //宽高
            content: '/sign/layout_open/getSignGift'
        });
    } else {
        // 当用户没有签到时
        if (href.indexOf('user') > -1) {
            $.ajax({
                url: '/sign/Sign_In_Api/run',
                type: 'post',
                data: {
                    signToken: signToken,
                    entrance: 2,
                },
                success: function (data) {
                    switch (data.status) {
                        case 200:
                            // 请求成功
                            if (data.status == 200) {
                                try {
                                    $(".sign-msg").html('今日已签到');
                                    $(".sign").addClass('signed');
                                    addCoupon(1, 13);//触发券行为
                                    var allSignCount = parseInt($(".allSignDays").text()) + 1;
                                    $(".allSignDays").text(allSignCount);
                                    var contSignCount = parseInt($(".sign-info-texter span").eq(0).text()) + 1;
                                    if(data.data.week_signed_rate == 12 ){
                                        // $(".sign-info-texter").html("本周累计签到<span>3</span>天，获得<span>1</span>下载币");
                                        $('.sign-days ul li').eq(2).addClass('current');
                                    }else if(data.data.week_signed_rate == 50 ){
                                        // $(".sign-info-texter").html("本周累计签到<span>5</span>天，获得抽奖券<span>1</span>张");
                                        $('.sign-days ul li').eq(4).addClass('current');
                                    }else if(data.data.week_signed_rate == 100 ){
                                        $('.sign-days ul li').eq(6).addClass('current');
                                        // $(".sign-info-texter").html("本周累计签到<span>7</span>天，获得充值代金券<span>1</span>张");
                                    }else{
                                        $(".sign-info-texter").html("本周累计签到<span>" + contSignCount + "</span>天");
                                    }
                                    if(data.data.week_signed_rate == 4 || data.data.week_signed_rate == 30 || data.data.week_signed_rate == 75 ){
                                        $('.sign-goods ul li').html('本周再签到1天可开启宝箱')
                                    }
                                    if(data.data.week_signed_rate == 2 ){
                                        $('.sign-goods ul li').html('本周再签到2天可开启宝箱')
                                    }
                                    if(data.data.week_signed_rate == 50 ){
                                        $('.sign-goods ul li').html('本周累计签到5天,获得抽奖券一张')
                                    }
                                    if(data.data.week_signed_rate == 12 ){
                                        $('.sign-goods ul li').html('本周累计签到3天,获得1下载币')
                                    }
                                    if(data.data.week_signed_rate == 100 ){
                                        $('.sign-goods ul li').html('本周累计签到7天,获得充值代金券一张')
                                    }
                                } catch (e) {
                                }
                                if (data.data.is_draw_gift) {
                                    try {
                                        var currentObj = $(".current");
                                        currentObj.addClass('active').removeClass('current');
                                        currentObj.next().addClass('current');
                                    } catch (e) {
                                    }
                                } else {
                                    try {
                                        $(".sign-days > ul").children().first().addClass('current');
                                    } catch (e) {
                                    }
                                }
                            }
                            layer.open({
                                type: 2, // 1（页面层）2（iframe层）
                                title: false,
                                id: '', // 弹窗唯一id
                                skin: 'layer-nobg', //自定义皮肤类
                                closeBtn: '1', //配置1和2来展示，如果不显示，则closeBtn: 0
                                area: ['460px', '431px'], //宽高
                                content: '/sign/layout_open/getSignGift'
                            });
                            // // 是否返回礼物
                            // if(data.data.is_draw_gift){
                            //     // 弹窗...
                            //     setTimeout(function(){
                            //         layer.open({
                            //             type: 2, // 1（页面层）2（iframe层）
                            //             title: false,
                            //             id:'', // 弹窗唯一id
                            //             skin:'layer-nobg', //自定义皮肤类
                            //             closeBtn:'1', //配置1和2来展示，如果不显示，则closeBtn: 0
                            //             area: ['420px', '371px'], //宽高
                            //             content: '/sign/layout_open/getDraw?gift_type='+data.data.gift_type+'&gift_numb='+data.data.add_zd+''
                            //         });
                            //     },500);
                            // }

                            break;
                        case 400:
                            // 请求失败
                            layer.msg(data.msg);
                            break;
                        case 501:
                            // 绑定手机...
                            layer.msg("请绑定手机，便于领取赠点与渲点");
                            setTimeout(function () {
                                objSite.openUserWin('/account/security/bindPhone', ['400px', '490px']);
                            }, 1000);
                            break;
                        case 502:
                            // 需要登录...
                            parent.openLogin();
                            break;
                        case 503:
                            // TOKEN失效
                            layer.msg(data.msg);
                            setTimeout(function () {
                                window.location.reload();
                            }, 1000);
                            break;
                        default:
                            break;
                    }

                },
                error: function (error) {
                    // console.log(error)
                }
            });
        }
    }
}

// 签到弹窗
function openSign(signToken) {
    var href = window.location.href;
    var load = layer.load(1);
    if (href.indexOf('user') > -1) {
        $.post('/sign/index/signIn', {
            signToken: signToken
        }, function (res) {
            if (res.status == 1) {
                try {
                    $(".sign-msg").html('已签到');
                } catch (e) {}
                if (res.data.signed_six > 1) {
                    try {
                        var currentObj = $(".current");
                        currentObj.addClass('active').removeClass('current');
                        currentObj.next().addClass('current');
                    } catch (e) {}
                } else {
                    try {
                        $(".sign-days > ul").children().first().addClass('current');
                    } catch (e) {}
                }
                try {
                    $(".allSignDays").html(res.data.signNums);
                } catch (e) {}
            }
            layer.open({
                type: 2,
                title: false,
                resize: false,
                area: ['650px', '358px'],
                content: ['/sign/index/index', 'no']
            });
            //layer.msg(res.msg);
        });
    } else {
        if (!objSite.isLogin()) {
            openLogin();
            return false;
        }
        objSite.ajaxUser('/sign/index/signIn', {
            signToken: signToken
        }, function (res) {
            // 抽奖弹窗
            if (res.status == 1) {
                try {
                    //$(".icon-b2").html('已签到');
                } catch (e) {}
            }
            var Url = objSite.getUserUrl('/sign/index/index');
            layer.open({
                type: 2,
                title: false,
                resize: false,
                area: ['650px', '358px'],
                content: [Url, 'no']
            });
            //layer.msg(res.msg);
        });
    }
    layer.close(load);
}
var lastClickTime = 0;
$(document).on('click', '.js-sign', function () {
    // 遮罩层盒子
    // $(".js-sign-mask").show();
    layer.closeAll();
    var token = $('#signToken').val();
    //$('.js-sign').css("pointer-events","none");
    var thisClickTime = new Date().getTime();
    if ((thisClickTime - lastClickTime) > 2000) {
        lastClickTime = thisClickTime;
        openSignNew(token);
    }

});
$(document).on('click', '.js-open-sign', function () {
    parent.layer.closeAll();
    var token = "";
    parent.openSignNew(token);
});

// 国家区号选择
function getNumber() {
    var tel_area = $('.selected-dial-code').text();
    $('.tel-area-code').attr('value', tel_area);
}

// 溜云库下载点击
$(document).on('click', '.click-log', function () {
    var click_type = $(this).data('click_type');
    var down_type = $(this).data('down_type');
    $.post(objSite.getKuUrl('/activity/index/clickLog'), {
        click_type: click_type,
        down_type: down_type
    });
});

// 顶部导航栏右侧埋点
//buried-info 埋点属性
// 列表页大类埋点www
$(document).on('click','.list-buried > li > a', function(event){
    event.preventDefault();
    var $shle = $(this)
    getBuried($shle,"1");
});
// 顶部导航埋点
$(document).on('click','.js_click_buried,.handler-buried a', function(event){
    // event.preventDefault();
    var $this = $(this)
    getBuried($this,"2");

    // seo页面埋点
    var locationUrl = window.location.href;
    var patt1 = new RegExp("relation");
    var result = patt1.test(locationUrl);
    if(result){
        var isList = $('div').hasClass('detail-swiper');
        var relationObj = {
            user_id: 0,
            uid: $.cookie("Hm_lvt_bh_ud") || 0,
            add_time: Math.floor(new Date().getTime()/1000),
            view_url: document.URL,
            title: $('title').text(),
            refer_url: document.referrer || '',
            relation_login: isList ? 2 : 1,
            buried_base_type: 'click_relation_register'
        };
        $.ajax({
            url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
            type: 'post',
            data: relationObj,
            xhrFields: {
                withCredentials: true
            },
            success: function(res){
            }
        });
    }
});
function getBuried(_this,nums){
    try {
        var href = _this.attr('href') || _this.children().attr('href') || _this.children().children().attr('href');
        var _blank = _this.attr('target') || _this.children().attr('target') || _this.children().children().attr('target');
        var buriedSource = '';
        var res_type = $('#resType').val();
        if(_this.attr('buried-info')){
            buriedSource = _this.attr('buried-info');
        }else{
            buriedSource = _this.parents('.handler-buried').find(_this).text() || _this.parents('.handler-buried').find(_this).children().text();
        }
        var channel_type = _this.attr('buried-type-info');
        // var res_list_page_type = _this.parents('.list-buried').attr('buried-list-info') || _this.attr('buried-list-info');
        var sourceObj = {
            report_time: Math.floor(new Date().getTime()/1000),
            view_url: document.URL,
            screen_width: window.screen.width,
            screen_height: window.screen.height,
            nav_click_id: '0',
            buried_base_type: _this.attr('buried_base_type') || _this.parents('.base_class_type').attr('buried_base_type') || "web_list_class_click"
        };
        if(res_type && sourceObj.view_url != objSite.getWwwUrl('/')){
            if(!_this.parent().attr('so_type')){
                sourceObj.res_type = res_type;
            }
        }
        if(buriedSource){
            sourceObj.nav_click_id = buriedSource
        }else if(channel_type){ //频道入口
            sourceObj.channel_type = channel_type
        }else if(_this.parents('.list-buried')){ //列表类
            sourceObj.res_list_page_type =  _this.parents('.list-buried').attr('buried-list-info')
            sourceObj.class_id = _this.parent().attr('data-cid')
        }
        $.ajax({
            url: objSite.getServiceUrl('/record/record/navClickRecord'),
            type: 'post',
            data: sourceObj,
            xhrFields: {
                withCredentials: true
            },
            success: function(res){
                if(nums == "1"){
                    if(href){
                        window.location.href = href
                    }
                }
            },
            error:function(){
                if(nums == "1"){
                    if(href){
                        window.location.href = href
                    }
                }
            }
        })
    } catch (error) {}
};

// 顶部导航栏埋点
$(document).on('click','.js_source_base', function(event){
    var source_prmam = $(this).attr('data-source');
    var href = $(this).attr('href')
    if(!$(this).hasClass('user-name')){
        try {   // 解决 返回“canceled” 或被取消
            event.preventDefault()
            $.ajax({
                url: objSite.getWwwUrl('/buried/tag_click'),
                type:'POST',
                data:{source: source_prmam},
                success: function(data){
                    if(href){
                        window.location.href=href
                    }
                },
                error: function(err){}
            })
        } catch (error) {}
    }else{
        // 针对头像跳转
        var user_href = $(this).find('.nav-link').children('a').attr('href');
        // console.log(user_href)
        try {   // 解决 返回“canceled” 或被取消
            event.preventDefault()
            $.ajax({
                url: objSite.getWwwUrl('/buried/tag_click'),
                type:'POST',
                data:{source: source_prmam},
                success: function(data){
                    window.location.href= user_href;
                },
                error: function(err){}
            })
        } catch (error) {}
    }
    
})

// 开年活动埋点
$(document).on('click','.js_year', function(event){
    var source_year = $(this).attr('data-year');

    try {
        if(window.location.protocol +'//'+ window.location.host+'/' == objSite.getServiceUrl('/')){  //判断是否跨域
            $.ajax({
                url: objSite.getServiceUrl('/api/v1/year2022/logPoint'),
                type:'POST',
                data:{source: source_year},
                success: function(data){
                    
                },
                error: function(err){
                }
            })
        }else{
            $.ajax({
                url: objSite.getServiceUrl('/api/v1/year2022/logPoint'),
                type:'POST',
                dataType:'jsonp',
                data:{source: source_year},
                success: function(data){
                },
                error: function(err){
                }
            })
        }
    } catch (error) {}
})

// 活动充值弹窗（常规充值和新用户充值弹窗）
function downloadCurrencyOpen(entrance, html){
    if (!objSite.isLogin()) {
        openLogin();
        return false;
    }
    var newthat = entrance == undefined ? 0 : entrance;
    if (newthat == undefined || newthat == 'undefined' || newthat == 0) {
        objSite.ajaxUser('/index/index/payErrLog', { html: html }, function (res) {});
    }

    $.ajax({
        type: "POST",
        crossDomain: true,
        dataType: 'jsonp',
        jsonp: 'callback',
        url: objSite.getServiceUrl('/activity202007/index/getUser'),
        timeout: 10000,
        //  默认情况下，标准的跨域请求是不会发送cookie的
        xhrFields: {
            withCredentials: true
        },
        success: function success(res) {
            if (res.code == 1) {

                // 材质增长实验：枚举值，判断来源
                if($("#resType").val() != "2"){
                    var entrance_cz = newthat;
                }else{
                    var entrance_cz = 174;
                }
                parent.layer.closeAll()
                if (res.not_charge == 0) {
                    parent.layer.open({
                        type: 2, // 1（页面层）2（iframe层）
                        title: false,
                        skin: 'layer-nobg layer-pay-pop', //自定义皮肤类
                        area: ['660px', '640px'], //宽高
                        content: objSite.getServiceUrl('/lb-pay-new-layout.html?newthat=' + entrance_cz + '&activity_id=61&restype=' + $("#resType").val() || ''),
                        cancel: function cancel(index, layero) {
                            // addCoupon(3, 15);
                            try {
                                // 材质增长埋点关闭
                                var getPreset = sessionStorage.getItem('dowloadInfo');
                                if(getPreset){
                                    getPreset = JSON.parse(getPreset)
            
                                    if(getPreset.res_type == 2){
                                        getPreset.up_time = Math.floor(new Date().getTime() / 1000);
                                        getPreset.details_page_lb_btn_content = 6;
                                        $.ajax({
                                            url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
                                            type: 'post',
                                            data: getPreset,
                                            xhrFields: {
                                                withCredentials: true
                                            },
                                            success: function(res){
                                                
                                            }
                                        })
                                    }
                                }
                            } catch (error) {}
                        }
                    });
                } else {
                    $.cookie("areaType", res.data);
                    var areaArr = res.data == 0 ? ['800px', '570px'] : ['900px', '693px'];
                    parent.layer.open({
                        type: 2, // 1（页面层）2（iframe层）
                        title: false,
                        id: '', // 弹窗唯一id
                        skin: 'layer-nobg', //自定义皮肤类
                        closeBtn: '1', //配置1和2来展示，如果不显示，则closeBtn: 0
                        area: areaArr, //宽高
                        content: objSite.getServiceUrl('/lb-pay-layout.html?entrance=' + entrance_cz + '&activity_id=61&restype=' + $("#resType").val() || ''),
                        cancel: function cancel(index, layero) {
                            // addCoupon(3, 15);
                            try {
                                // 材质增长埋点关闭
                                var getPreset = sessionStorage.getItem('dowloadInfo');
                                if(getPreset){
                                    getPreset = JSON.parse(getPreset)
                                
                                    if(getPreset.res_type == 2){
                                        getPreset.report_time = Math.floor(new Date().getTime() / 1000);
                                        getPreset.details_page_lb_btn_content = 6;
                                        $.ajax({
                                            url: objSite.getServiceUrl('/record/record/navClickRecord'),
                                            type: 'post',
                                            data: getPreset,
                                            xhrFields: {
                                                withCredentials: true
                                            },
                                            success: function(res){
                                                
                                            }
                                        })
                                    }
                                }
                            } catch (error) {}
                            
                        }
                    });
                }
            }
        }
    });
};


// 活动支付弹窗
function openActPay(bg, color, package_id, activity_id, cz_channel, cz_source) {
    var client = navigator.userAgent;
    var user_token = '';
    var url;
    if (client == '3d66') {
        //渲点客户端
        user_token = ThirdPlatformWebView.getTokenKey();

        if (!user_token) {
            layer.msg('请先登录');
            return false;
        }
        url = objSite.getServiceUrl('/pay/activity_pay_page?package_id=' + package_id + '&activity_id=' + activity_id + '&cz_channel=' + cz_channel + '&cz_source=' + cz_source + '&user_token=' + user_token);

    } else if (client == '3DPlug3') {
        //魔术后客户端
        user_token = GetGroupId();
        user_token = user_token.open_id;

        if (!user_token) {
            layer.msg('请先登录');
            return false;
        }
        url = objSite.getServiceUrl('/pay/activity_pay_page?package_id=' + package_id + '&activity_id=' + activity_id + '&cz_channel=' + cz_channel + '&cz_source=' + cz_source + '&user_token=' + user_token);
    } else {
        //判断是否有登录
        if (!objSite.isLogin()) {
            openLogin();
            return false;
        }
        url = objSite.getServiceUrl('/pay/activity_pay_page?package_id=' + package_id + '&activity_id=' + activity_id + '&cz_channel=' + cz_channel + '&cz_source=' + cz_source);
    }
    layer.open({
        type: 2,
        title: false,
        resize: false,
        area: ['800px', '430px'],
        content: url,
        success: function (layero, index) {
            var body = layer.getChildFrame('body', index);
            var iframeWin = window[layero.find('iframe')[0]['name']];
            body.find('.left').css('background-image', 'url(' + bg + ')');
            body.find('.left h2').css('color', color);
        },
        cancel: function(index, layero){
            if (cz_channel == 3) {
                addCoupon(5, 18);
            } else if (cz_channel == 1) {
                addCoupon(3, 15);
            }
        }
    });
}

// 新版活动支付弹窗
function openActPayNew(classname, package_id, activity_id, cz_channel, cz_source, entrance, benefits,user_retrieve) {
    if (typeof (entrance) == 'undefined') {
        entrance = 0;
    }
    if (typeof (benefits) == 'undefined') {
        benefits = 0;
    }
    if (typeof (user_retrieve) == 'undefined') {
        user_retrieve = 0;
    }
    var client = navigator.userAgent;
    var user_token = '';
    var url;
    if (client == '3d66') {
        //渲点客户端
        user_token = ThirdPlatformWebView.getTokenKey();

        if (!user_token) {
            layer.msg('请先登录');
            return false;
        }
        url = objSite.getServiceUrl('/pay/activity_pay_page?package_id=' + package_id + '&activity_id=' + activity_id + '&cz_channel=' + cz_channel + '&cz_source=' + cz_source + '&user_token=' + user_token);

    } else if (client == '3DPlug3') {
        //魔术后客户端
        user_token = GetGroupId();
        user_token = user_token.open_id;

        if (!user_token) {
            layer.msg('请先登录');
            return false;
        }
        url = objSite.getServiceUrl('/pay/activity_pay_page?package_id=' + package_id + '&activity_id=' + activity_id + '&cz_channel=' + cz_channel + '&cz_source=' + cz_source + '&user_token=' + user_token);
    } else {
        //判断是否有登录
        if (!objSite.isLogin()) {
            openLogin();
            return false;
        }
        url = objSite.getServiceUrl('/pay/activity_pay_page?package_id=' + package_id + '&activity_id=' + activity_id + '&cz_channel=' + cz_channel + '&cz_source=' + cz_source + '&entrance=' + entrance + '&benefits=' + benefits +'&user_retrieve='+user_retrieve);
    }
    if(package_id == 1410 || package_id == 1411 || package_id == 1402 || package_id == 1403 || package_id == 1404){ //开年活动专属判断
        parent.layer.open({
            type: 2,
            title: false,
            resize: false,
            area: ['800px', '430px'],
            content: url,
            success: function (layero, index) {
                var body = parent.layer.getChildFrame('body', index);
                var iframeWin = window[layero.find('iframe')[0]['name']];
                body.find('.left').addClass(classname);
            },
            cancel: function (index, layero) {
                if (cz_channel == 3) {
                    addCoupon(5, 18);
                } else if (cz_channel == 1) {
                    addCoupon(3, 15);
                }
                
                newYearsPayOpen(entrance,package_id, benefits);
            }
        });
    }else{
        layer.closeAll();
        parent.layer.open({
            type: 2,
            title: false,
            resize: false,
            area: ['800px', '430px'],
            content: url,
            success: function (layero, index) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = window[layero.find('iframe')[0]['name']];
                var leftEl = $(layero.find('iframe')[0].contentWindow.document.body).find('.left')
                body.find('.left').addClass(classname);
                // 两个弹窗重叠判断
                if(!leftEl.hasClass(classname)){
                    leftEl.addClass(classname)
}
            },
            cancel: function (index, layero) {
                if (cz_channel == 3) {
                    addCoupon(5, 18);
                } else if (cz_channel == 1) {
                    addCoupon(3, 15);
                }

                newYearsPayOpen(entrance,package_id, benefits);
                // newYearsActs();
            }
        });
    }
}

// 在开年活动中关闭充值弹窗触发
function newYearsPayOpen(entrance,package_id,benefits){
    if(window.location.href.indexOf('activity202301') > -1){
        var userData = $.cookie('userCookieData') ? JSON.parse($.cookie('userCookieData')) : '';
        var endDate = new Date();
        endDate.setDate(endDate.getDate()+1);
        endDate.setHours(0);
        endDate.setMinutes(0);
        endDate.setSeconds(0);
        if(!$.cookie("gifts")){
            $.cookie("gifts",'ok',{ 
                expires: 3,
                domain: '3d66.com',
                path: '/'
            }); 
            layer.open({
                type: 2,
                shade: 0.3,
                skin: 'layer-nobg',
                title: false,
                resize: false,
                area: ['696px','490px'],
                content: objSite.getServiceUrl('/activity202301/user_retrieve.html?entrance='+entrance+'&package_id='+package_id+'&benefits='+benefits),
                cancel: function (index, layero) {
                    try {
                        var obj = {
                            user_id: userData.user_id || 0,
                            add_time: Math.floor(new Date().getTime() / 1000) || 0,
                            refer_url: document.referrer,
                            view_url : window.location.href || '',
                            buried_base_type:'activity_openyear_popup_retain_button_click',
                            openyear_popup_retain_click_button: 2
                        }
                        $.ajax({
                            url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
                            type: 'post',
                            data: obj,
                            xhrFields: {
                                withCredentials: true
                            },
                            success: function(res){}
                        });
                    } catch (error) {}
                    
                }
            });
        };
    }
};

// 已经下线预留
function newYearsActs(){
    // 开年活动
    if(window.location.href.indexOf('activity202301') > -1) return false;
    if($('.red-items').length > 0) return false;
    var userInfos = $.cookie('userCookieData') ? JSON.parse($.cookie('userCookieData')) : '';
    var buried_user_id = 0;
    if(userInfos != ''){
        buried_user_id = userInfos.user_id
    }else {
        buried_user_id = 0
    }
    $.ajax({
        url: objSite.getServiceUrl('/api/v1/Act202301/checkPop'),
        type: 'post',
        xhrFields: {
            withCredentials: true
        },
        data: {pop_type: 2},
        success: function(res){
            if(res.code == 1 && res.status == 1){
                if(res.data.status == 3){
                    layer.open({
                        type: 2,
                        shade: 0.3,
                        skin: 'layer-nobg',
                        title: false,
                        resize: false,
                        area: ['949px','597px'],
                        content: objSite.getServiceUrl('/activity202301/pop_up1.html'),
                        cancel: function (index, layero) {
                            try {
                                var obj = {
                                    user_id: buried_user_id || 0,
                                    add_time: Math.floor(new Date().getTime() / 1000) || 0,
                                    openyear_platform_port: 2,
                                    refer_url: document.referrer,
                                    view_url : window.location.href || '',
                                    buried_base_type:'activity_openyear_popup_button_click',
                                    openyear_popup_type: 1,
                                    openyear_popup_click_button: 3
                                }
                                $.ajax({
                                    url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
                                    type: 'post',
                                    data: obj,
                                    xhrFields: {
                                        withCredentials: true
                                    },
                                    success: function(res){}
                                })
                            } catch (error) {}
                        }
                    });
                }else if(res.data.status == 4){
                    layer.open({
                        type: 2,
                        shade: 0.3,
                        skin: 'layer-nobg',
                        title: false,
                        resize: false,
                        area: ['700px','420px'],
                        content: objSite.getServiceUrl('/activity202301/pop_up3.html'),
                        cancel: function (index, layero) {
                            try {
                                var obj = {
                                    user_id: buried_user_id || 0,
                                    add_time: Math.floor(new Date().getTime() / 1000) || 0,
                                    openyear_platform_port: 2,
                                    refer_url: document.referrer,
                                    view_url : window.location.href || '',
                                    buried_base_type:'activity_openyear_popup_button_click',
                                    openyear_popup_type: 4,
                                    openyear_popup_click_button: 3
                                }
                                $.ajax({
                                    url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
                                    type: 'post',
                                    data: obj,
                                    xhrFields: {
                                        withCredentials: true
                                    },
                                    success: function(res){}
                                })
                            } catch (error) {}
                        }
                    });
                }
            }
        }
    })
}

// 正常支付弹窗
// 充值渠道(1溜币充值，2渲点充值，3vip充值，4魔术手, 5商城支付)
var loadPay = '';

function openNormalPay(package_id, cz_channel, cz_type, cz_source, cz_month, discount_id) {
    //获取渲染客户端标识
    var client = navigator.userAgent;
    var user_token = '';
    if (client == '3d66') {
        //渲点客户端
        user_token = ThirdPlatformWebView.getTokenKey();

        if (!user_token) {
            layer.msg('请先登录');
            return false;
        }
    } else if (client == '3DPlug3') {
        //魔术后客户端
        user_token = GetGroupId();
        user_token = user_token.open_id;

        if (!user_token) {
            layer.msg('请先登录');
            return false;
        }
    } else {
        //判断是否有登录
        if (!objSite.isLogin()) {
            openLogin();
            return false;
        }
    }

    var data = {
        package_id: package_id,
        cz_channel: cz_channel,
        cz_source: cz_source,
        cz_type: cz_type,
        user_token: user_token
    };
    var create_order_url = objSite.getServiceUrl('/pay/normal_create_order');

    //魔术手
    if (cz_channel == 4) {
        data = {
            package_id: package_id,
            cz_channel: cz_channel,
            cz_source: cz_source,
            cz_type: cz_type,
            cz_month: cz_month,
            discount_id: discount_id
        };
    }

    //魔术手
    if (cz_channel == 4) {
        data = {
            package_id: package_id,
            cz_channel: cz_channel,
            cz_source: cz_source,
            cz_type: cz_type,
            cz_month: cz_month,
            discount_id: discount_id
        };
    }

    $.ajax({
        type: "POST",
        url: create_order_url,
        data: data,
        async: false,
        success: function (res) {
            if (res.status == 0) {
                layer.msg(res.msg);
                return false;
            }
            var result = JSON.parse(res.msg);
            $('#jkma').val(result.data);
            switch (cz_type) {
                case 0:
                    if (res.status == 0) {
                        layer.msg(res.msg);
                        return false;
                    }
                    layer.open({
                        type: 2,
                        title: false,
                        resize: false,
                        area: ['315px', '373px'],
                        content: objSite.getServiceUrl('/pay/normal_qr_code_page?data=' + result.data)
                    });
                    return false;
                    break;
                case 2:
                    $('.pay-click').attr('action', objSite.getServiceUrl('/pay/create_alipay_pc'));
                    $('.pay-click').submit();
                    checkPay(result, cz_channel);
                    break;
                case 3:
                    $('.pay-click').attr('action', objSite.getServiceUrl('/pay/create_paypal'));
                    $('.pay-click').submit();
                    checkPay(result, cz_channel);
                    break;
                    break;
                default:
                    break;
            }
        }
    });
}

function openCompanyPay(package_id, cz_channel, cz_type, cz_source, gift_check, gift_radio) {
    //判断是否登录
    /*if (!objSite.isLogin()) {
        openLogin();
        return false;
    }*/
    var data = {
        package_id: package_id,
        cz_channel: cz_channel,
        cz_type: cz_type,
        cz_source: cz_source,
        gift_check: gift_check,
        gift_radio: gift_radio
    };
    var create_order_url = objSite.getServiceUrl('/pay/normal_create_order');

    $.ajax({
        type: "POST",
        url: create_order_url,
        data: data,
        async: false,
        success: function (res) {
            if (res.status == 0) {
                layer.msg(res.msg);
                return false;
            }
            var result = JSON.parse(res.msg);
            $('#jkma').val(result.data);
            switch (cz_type) {
                case 0:
                    if (res.status == 0) {
                        layer.msg(res.msg);
                        return false;
                    }
                    layer.open({
                        type: 2,
                        title: false,
                        resize: false,
                        area: ['315px', '373px'],
                        content: objSite.getServiceUrl('/pay/normal_qr_code_page?data=' + result.data)
                    });
                    return false;
                    break;
                case 2:
                    $('.pay-click').attr('action', objSite.getServiceUrl('/pay/create_alipay_pc'));
                    $('.pay-click').submit();
                    checkPay(result, cz_channel);
                    break;
                case 3:
                    $('.pay-click').attr('action', objSite.getServiceUrl('/pay/create_paypal'));
                    $('.pay-click').submit();
                    checkPay(result, cz_channel);
                    break;
                    break;
                default:
                    break;
            }
        }
    });
}

// 检查是否支付
function checkPay(result, cz_channel) {
    clearInterval(loadPay);
    loadPay = setInterval(function () {
        var url = objSite.getServiceUrl('/pay/check_pay');
        $.post(url, {
            service: "ll.order.check",
            jkma: result.original_jkma,
            cz_channel: cz_channel
        }, function (res) {
            if (res.status === 200) {
                layer.msg('支付成功');
                clearInterval(loadPay);
                switch (cz_channel) {
                    case 1:
                        var return_url = objSite.getUserUrl('pay/index_list/index');
                        break;
                    case 2:
                        var return_url = objSite.getUserUrl('/pay/vip_list/index');
                        break;
                    case 3:
                        var return_url = objSite.getUserUrl('/pay/xuanran_list/index');
                        break;
                    case 4:
                        var return_url = objSite.getUserUrl('/pay/plug_list/index');
                        break;
                    case 5:
                        var return_url = objSite.getShopUrl('/order_1_2.html');
                        break;
                    default:
                        var return_url = objSite.getUserUrl('/pay/index_list/index');
                        break;
                }
                setInterval(function () {
                    parent.window.location.href = return_url;
                }, 1000);

            }
        })
    }, 2000);
}

//点击行为触发事件
function codeVeri(msg) {
    var dataList = ["0", "1"];
    var options = {
        dataList: dataList,
        success: function (token) {
            // 成功回调
            setTimeout(function(){
                $("#llValidation").hide();
            },1000)
            var url = objSite.getUserUrl('/validate/click_select_validate/checkBlackboxDownload');
            $.post(url, {
                token: token,
            }, function (res) {
                layer.closeAll('loading');
                layer.msg(res.msg);
                if (res.code == 1) {
                    setTimeout(function () {
                        layer.closeAll();
                        window.location.reload();
                    }, 1000);
                }
            });
        },
        fail: function () {
            // alert("失败")
            // console.log("fail");
        }
    };
    SliderBar("llValidation", options);
}

//滑块行为触发事件
function sliderVeri(msg) {
    var dataList = ["0", "1"];
    var options = {
        dataList: dataList,
        success: function (token) {
            // 成功回调
            setTimeout(function(){
                $("#llValidation").hide();
            },1000)
            var url = objSite.getUserUrl('/validate/Slider_Validate/check');
            $.post(url, {
                token: token,
            }, function (res) {
                layer.closeAll('loading');
                layer.msg(res.msg);
                if (res.code == 1) {
                    setTimeout(function () {
                        layer.closeAll();
                    }, 1000);
                }
                return;
            });
        },
        fail: function () {
            // alert("失败")
            // console.log("fail");
        }
    };
    SliderBar("llValidation", options);
};

/**
 * 加密字符串
 * @param pubkeyName
 * @param value
 * @returns {string}
 */
function encrypt(pubkeyName, value) {
    try{
        var encrypt = new JSEncrypt();
        var pubKey = config('jsencrypt');
        if (!pubKey.hasOwnProperty(pubkeyName)) {
            throw 'There is no "' + pubkeyName + '" encryption string in the current configuration file.';
        }

        var dataType = typeof value;
        if (dataType !== 'string') {
            throw 'Invalid param: type check failed for param "format". Expected "string", got "' + dataType + '".';
        }

        encrypt.setPublicKey(pubKey[pubkeyName]);
        return encrypt.encrypt(value);
    }
    catch(err){
        console.log('err:',err)
    }


}
function sotuUpImg(search_data, objData,sotuResType,isType) {
    //判断是否登录
    if(!objSite.isLogin()){
        $(".search-area").css("display","none");
        openLogin();
        return false;
    }
    var searchType = objData.searchType || 1;
    var originUrl = objData.originUrl || "";
    var resType = objData.resType || 0;
    var searchSource = objData.searchSource || 1;
    var actionId = objData.actionId || "";
    var llid = objData.llid || 0;
    var imgid = objData.imgid || 1;
    var index = null;

    var sotu_data = new FormData();
    // console.log(searchType);
    if (searchType == 1) {
        var fileName = search_data.name;
        var suffixName = fileName.substring(fileName.lastIndexOf('.')).toLowerCase();
        var AllImgExt = ".jpg|.jpeg|.gif|.png|";
        var fileSize = search_data.size;
        //if(fileSize > 2 * 1024 * 1024 || fileSize < 1 * 1024)

        if (fileSize > 4 * 1024 * 1024) {
            layer.msg("图片大小错误，请选择小于4M的图片");
            return false;
        }
        if (AllImgExt.indexOf(suffixName + '|') == -1) {
            layer.msg("文件格式错误，请上传图片！");
            //不支持改格式
            return false;
        }
        sotu_data.append('refer_url', document.referrer);
        sotu_data.append('sotuRequest', search_data);
        sotu_data.append('searchType', searchType);
        // console.log(sotu_data);
    } else if (searchType == 4) {
        sotu_data.append('searchType', 4);
        sotu_data.append('searchSource', searchSource);
        sotu_data.append('resType', resType);
        sotu_data.append('sotuRequest', search_data);
        sotu_data.append('originImgUrl', originUrl);
        sotu_data.append('actionId', actionId);
        sotu_data.append('llid', llid);
        sotu_data.append('imgid', imgid);
        sotu_data.append('sotuResType', sotuResType);
    } else {
        sotu_data.append('sotuRequest', search_data);
        sotu_data.append('searchType', searchType);
    }

    $.ajax({
        type: "POST",
        url: objSite.getWwwUrl('/sotu/sotu_api'),
        data: sotu_data,
        processData: false,
        contentType: false,
        xhrFields: {
            withCredentials: true
        },
        beforeSend: function (request) {
            $('.js_Loading').removeClass('show');
            if (searchType == 4) {
                index = layer.load(1);
            } else {
                index = layer.msg('识别中', {
                    icon: 16,
                    shade: 0.01
                });
            }
        },
        success: function (data) {

            if (data.status == 0) {
                layer.alert(data.msg, {
                    icon: 2
                });
                layer.close(index);
                return false;
            } else if (data.status == 2) {
                layer.close(index);
                layer.msg(data.msg);
                setTimeout(function () {
                    openLogin();
                }, 1000);
                return false;
            } else if(data.status == 100){
                //轻度冻结
                layer.close(index);
                layer.msg(data.msg);
                setTimeout(function () {
                    layer.open({
                        type: 2,
                        title: false,
                        resize: false,
                        area: ['460px', '320px'],
                        content: [objSite.getUserUrl('/account/Account_Status_Layout/index?status=2'), 'no'],
                    });
                }, 1000);
                return false;
            } else {
                layer.close(index);
                $(".search-area").hide();
                if (searchType == 4) {
                    if (!$('#action_id').val()) {
                        $('#action_id').val(data.action_id);
                    }
                    
                    $.each(data.data, function (i, item) {
                        //var idText = 'id:' + item.llid;
                        $('.results-lists').append("<li>" +
                            "<a target='_blank' class='search-list-items' href='javascript:void(0)'>" +
                            "<img class='lazy' data-original='" + item.img_url + "' src='" + item.img_url + "'/> " +
                            "</a>" +
                            "<div onclick='bindSimilarEvent(this)' class='search-list-similar js-search-similar' data-llid='" + item.llid + "' data-imgid='" + item.imgid + "'>" +
                            "<span class='similar-btn'><i class='search-icon'><b class='icon-text-name'></b></i></span>" +
                            "</div>" +
                            "<div class='search-list-text clearfix'>" +
                            "<span class='text-name'>" + item.res_name + "</span>" +
                            //"<span class='text-id'>" + idText + "</span>" +
                            "</div>" +
                            "</li>");
                            if((i + 1) == data.data.length){
                                if(isFirefox=navigator.userAgent.indexOf("Firefox")>0 || !!window.ActiveXObject || "ActiveXObject" in window){  //判断是否是火狐浏览器
                                    objSite.obj.data = true;
                                }
                                layer.close(layerIndex);
                                $(".search-area").hide();
                            }
                    });
                    $(".lazy").lazyload({
                        effect : "fadeIn"
                    });
                    // bindSimilarEvent();
                    //显示
                    // layer.close(index);
                    //底线显示
                    $('div.results-container .bottom-line').hide();
                } else if (searchType == 2) {
                    if(isType){ //以图搜图
                        var layerIndex = null;
                        var sotu_prarms = new FormData();
                        sotu_prarms.append('searchType', 4);
                        sotu_prarms.append('searchSource', searchSource);
                        sotu_prarms.append('resType', resType);
                        sotu_prarms.append('sotuRequest', data.data);
                        sotu_prarms.append('originImgUrl', originUrl);
                        sotu_prarms.append('actionId', actionId);
                        sotu_prarms.append('llid', llid);
                        sotu_prarms.append('imgid', imgid);
                        sotu_prarms.append('sotuResType', sotuResType);
                        sotu_prarms.append('refer_url', document.referrer);
                        // console.log()
                        $.ajax({
                            type: "POST",
                            url: objSite.getWwwUrl('/sotu/sotu_api'),
                            data: sotu_prarms,
                            processData: false,
                            contentType: false,
                            xhrFields: {
                                withCredentials: true
                            },
                            beforeSend: function (request) {
                                layerIndex = layer.msg('读取数据中...', {
                                    icon: 16,
                                    time: 1000 * 120,
                                    shade: 0.01
                                });
                            },
                            success: function (res) {
                                if(res.status == 1){
                                    if (!$('#action_id').val()) {
                                        $('#action_id').val(res.action_id);
                                    }
                                    $('.results-lists li').remove();
                                    $.each(res.data, function (i, item) {
                                        //var idText = 'id:' + item.llid;
                                        $('.results-lists').append("<li>" +
                                            "<a target='_blank' class='search-list-items' href='javascript:void(0)'>" +
                                            "<img class='lazy' data-original='" + item.img_url + "' src='" + item.img_url + "'/> " +
                                            "</a>" +
                                            "<div onclick='bindSimilarEvent(this)' class='search-list-similar js-search-similar' data-llid='" + item.llid + "' data-imgid='" + item.imgid + "'>" +
                                            "<span class='similar-btn'><i class='search-icon'><b class='icon-text-name'></b></i></span>" +
                                            "</div>" +
                                            "<div class='search-list-text clearfix'>" +
                                            "<span class='text-name'>" + item.res_name + "</span>" +
                                            //"<span class='text-id'>" + idText + "</span>" +
                                            "</div>" +
                                            "</li>");

                                            if ((i + 1) == res.data.length) {
                                                if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0 || !!window.ActiveXObject || "ActiveXObject" in window) {  //判断是否是火狐浏览器
                                                    objSite.obj.data = true;
                                                }
                                                layer.close(layerIndex);
                                                $(".search-area").hide();
                                            }
                                    });
                                    $(".lazy").lazyload({
                                        effect : "fadeIn"
                                    });
                                    $(".results-lists").animate({scrollTop:0},100)
                                }else if(res.status == 0){
                                    layer.msg(res.msg);
                                } else if (data.status == 100){
                                    //轻度冻结
                                    layer.msg(data.msg);
                                    setTimeout(function () {
                                        layer.open({
                                            type: 2,
                                            title: false,
                                            resize: false,
                                            area: ['460px', '320px'],
                                            content: [objSite.getUserUrl('/account/Account_Status_Layout/index?status=2'), 'no'],
                                        });
                                    }, 1000);
                                }
                            },
                            error: function(err){
                                console.log('err：',err)
                            }
                        })
                    }else{
                        window.location.href = objSite.getWwwUrl('/sotu/search_result/index/' + resType + '-' + searchSource + '?file_img=' + data.data + '&original_img=' + originUrl);
                    }

                } else {
                   window.location.href = objSite.getWwwUrl('/sotu/search_result/index/' + resType + '-' + searchSource + '?file_img=' + data.data);
                }
            }
        },
        error: function () {
            layer.alert("服务异常，请稍后再试", {
                icon: 2
            });
            layer.close(index);
        },
        complete: function (xhr, ts) {
            // $('.js-search-word,.input-url').attr('placeholder', '搜索溜溜ID、关键词、以图搜图或图片地址');
        }
    });
}

//新窗口打开
function newOpenWindow(url) {
    var a = document.createElement('a');
    a.setAttribute('href', url);
    a.setAttribute('rel', 'nofollow');
    a.setAttribute('style', 'display:none');
    a.setAttribute('target', '_blank');
    document.body.appendChild(a);
    a.click();
    a.parentNode.removeChild(a);
};

$(document).on('click', '#dialogClose,.layer-popup-ques-close', function () {
    layer.closeAll();
});

$(document).on('click', '#dialogClose2', function () {
    $("#freeDownDialog").css("display","none");
    layer.closeAll();
});
/**
 * 获取url参数值
 * @param name 参数名
 */
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
};

/**
 * 判断是否是json格式
 * @param str
 * @returns {boolean}
 */
function isJSON(str) {
    if (typeof str == 'string') {
        try {
            var obj = JSON.parse(str);
            return !!(typeof obj == 'object' && obj);
        } catch (e) {
            return false;
        }
    }
    new Error('It is not a string!');
};

/**
 * 禁止浏览器后退
 */
function noBackOff() {
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', function () {history.pushState(null, null, document.URL); });
}

// IE 兼容方法
if (typeof Object.assign != 'function') {
    Object.assign = function(target) {
        'use strict';
        if (target == null) {
            throw new TypeError('Cannot convert undefined or null to object');
        }

        target = Object(target);
        for (var index = 1; index < arguments.length; index++) {
            var source = arguments[index];
            if (source != null) {
                for (var key in source) {
                    if (Object.prototype.hasOwnProperty.call(source, key)) {
                        target[key] = source[key];
                    }
                }
            }
        }
        return target;
    };
}

/**
 * 一个简单的js页面对象
 * @param options
 * @returns {*}
 * @constructor
 */
function View(options) {
    this.$data = {};
    var defOptions = {
        construct: function () {
            this.beforeCreate();
            this.created();
            this.mounted();
            this.beforeUpdate();
            this.updated();
            this.beforeDestroy();
            this.destroyed();
        },
        data: function () {},
        computed: {},
        watch: {},
        beforeCreate: function () {},
        created: function () {},
        mounted: function () {},
        beforeUpdate: function () {},
        updated: function () {},
        beforeDestroy: function () {},
        destroyed: function () {},
        methods: {}
    };
    options = typeof options == 'object' ? options : {};
    this.options = Object.assign(defOptions, options);

    for (var attr in this.options) {
        if (!this.options.hasOwnProperty(attr)) continue;
        this[attr] = this.options[attr];
    }

    // 将 methos 里的方式绑定到 this 里
    var methods = this.methods;
    for (var method in methods) {
        if (!methods.hasOwnProperty(method)) continue;
        this[method] = methods[method];
    }

    // 将 data 里的数据绑定到 this 里
    var data = this.data();
    for (var key in data) {
        if (!data.hasOwnProperty(key)) continue;
        this.$data[key] = data[key];
    }
    return this.construct();
}

// 新版签到埋点
objSite.SignBurialPoint = function(positionClick,viewUrl){
    $.ajax({
        url: objSite.getServiceUrl('/activityunion/sign/advertisingOrSignBuriedPoint?position_click_checkin='+positionClick+'&view_url='+viewUrl),
        type: 'get',
        xhrFields: {
            withCredentials: true
        },
        success: function(res){}
    })
}
// 埋点
objSite.basePoint = function(textVal){
    $.ajax({
        type: 'post',
        url: objSite.getUserUrl('/index/Point/?name='+ textVal),
        success: function(res){}
    })
};
// 贵族VIP弹窗
// 添加原因：由于定义函数方式有问题，有些页面直接调取不到，导致需要每一个js都要重新添加，所以重新定义一个
objSite.newVipPopup = function(type, entrance, classType, repeatType){
    if (type == 1) {
        //vip
        var activity_id = 0;
        var cz_channel = 2;
        var cz_source = 0;
    } else if (type == 2) {
        //素材贵族
        var activity_id = 0;
        var cz_channel = 14;
        var cz_source = 1;
    } else if (type == 3) {
        //渲染贵族
        var activity_id = 0;
        var cz_channel = 6;
        var cz_source = 0;
    } else if (type == 4) {
        //自学贵族
        var activity_id = 0;
        var cz_channel = 9;
        var cz_source = 0;
    } else if (type == 5) {
        //全景贵族
        var activity_id = 0;
        var cz_channel = 20;
        var cz_source = 0;
    } else {
        return false;
    }
    var pay_type = '';
    if (classType) {
        pay_type = "&pay_type=" + classType;
    }
    var repeat_type = '';
    if (repeatType) {
        repeat_type = "&repeat_type=" + repeatType;
        layer.closeAll();
    }
    //统一弹窗
    layer.open({
        type: 2,
        skin: 'new-layer-nobg',
        title: false,
        resize: false,
        area: ['1000px', '610px'],
        content: objSite.getServiceUrl('/pay/new_vip_page/index?type=' + type + '&cz_channel=' + cz_channel + '&cz_source=' + cz_source + '&activity_id=' + activity_id + '&entrance=' + entrance + pay_type + repeat_type),
        success: function success(layero, index) {
            try {
                if (parent.location.hash === '#zixueVip') {
                    parent.location.hash = '';
                }
            } catch (e) {
                //TODO handle the exception
            }
        },
        cancel: function cancel(index, layero) {
             // 会员节活动未支付弹窗
            var jkma = $('#layui-layer-iframe'+index).contents().find('#jkma').val();
            var vip_repeat_down_active =  $('#layui-layer-iframe'+index).contents().find('#vip_repeat_down_active').val();
            // $.post(objSite.getServiceUrl('/pay/check_pay'), {
            //     service: "ll.order.check",
            //     jkma: jkma,
            //     cz_channel: cz_channel,
            //     vip_repeat_down_active: vip_repeat_down_active
            // }, function(res) {
            //     if (res.status == 202) {
            //         layer.open({
            //             type: 2,
            //             closeBtn: 1,
            //             title: '',
            //             skin: 'layer-nobg',
            //             //加上边框
            //             area: ['600px', '600px'],
            //             //宽高
            //             content: objSite.getServiceUrl('/activity202209/viph5/newUser'),
            //             success: function success(layero, index) {},
            //             cancel: function cancel(index, layero) {
            //                 // $('.right-time-limit').fadeIn();
            //             }
            //         });
            //     }
            // });
            if (type == 5) {
                addCoupon(7, 25); 
            }
            var iframeContent = $('.new-layer-nobg iframe').contents();
            if (iframeContent.find('.new-vip-tab>a.active').index() == 0 && iframeContent.find('#surplus-coupon').val() == 0 && iframeContent.find('.whole-website .vip-type-tab li.active').data('coupon') == 1 && $.cookie('surplusCoupon') != 1) {
                $.cookie('surplusCoupon', '1', { expires: 1 });
                $('.new-layer-nobg iframe')[0].contentWindow.layerExtension(iframeContent.find('.vip-type-tab li.active').data('open_year'));
                return false;
            }
        }
    });
};
// 兼容IE9 搜索功能
try{
    var browser=navigator.appName
    var b_version=navigator.appVersion
    var version=b_version.split(";");
    var trim_Version=version || version[1].replace(/[ ]/g,"");
    if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE9.0"){
        var script = document.createElement("script");
            script.type = "text/javascript";
            script.src = objSite.getStaticUrl("/www2/js/public/jquery.xdomainrequest.min.js");
        var currentScript = document.currentScript || (function() {  //获取当前文件加载的dom
            var scripts = document.getElementsByTagName('script');
            return scripts[scripts.length - 1];
        })();
        var bodyNode = document.getElementsByTagName('body')[0];
        bodyNode.insertBefore(script,currentScript);
    };
} catch(err){
    console.log('err:',err)
}

// 自学头像区域选中优化
var headImgTimer;
var newsCount = 1;
// 鼠标移入事件
$(".js_Myself").mouseover(function(){
    headImgTimer && clearInterval(headImgTimer);
    newsCount = 1
    $(".user-info-content").css({"opacity":"1","transform":"scale(1)"});
});
$(".js_Myself").mouseleave(function(){
    headImgTimer && clearInterval(headImgTimer);
    headImgTimer = setInterval(function(){
        //让透明度渐减，直至为零
        newsCount = (newsCount*1) - (0.5 * 1);
        $(".user-info-content").css({"opacity":newsCount});
            if(newsCount <= 0){
                $(".user-info-content").css({"opacity":"0","transform":"scale(0.01)"});
                clearInterval(headImgTimer);
            }
        },70);
        //最后复原透明度，成为下次的开始值
        newsCount=1;
});


// 世界杯入口点击事件
$('body').on('click','.js_hover_buried',function(){
	// ['397px', '447px'],$(".js_exchange_gold"),'show-layer-close show-layer-close-team'
	layer.open({
		type: 2,
		resize: false,
		skin: 'team-layui-back',
		title: '',   //标题
		area: ['1100px', '700px'],   //宽高  http://www.dev.3d66.com/activity202211_world
		shade: 0.4,   //遮罩透明度
		content: objSite.getWwwUrl('/activity202211_world'),//支持获取DOM元素
		btn: '', //按钮组
		// scrollbar: false ,//屏蔽浏览器滚动条
		yes: function(index){//layer.msg('yes');    //点击确定回调
			layer.close();
		},
		btn2: function(){//layer.alert('aaa',{title:'msg title'});  点击取消回调
			// layer.msg('bbb');//layer.closeAll();
		},
		cancel: function(index, layero){
			var dataObj = {
				buried_base_type:'worldcup_click_column',
				worldcup_clickcolumn:'4',
			}
			objSite.buriedBuriedNewObj(dataObj);
		}
	});
});

// 世界杯竞猜埋点
$('body').on('click','.js_team_Buried',function(){
    var clickcolumn = $(this).attr('data-Buried');
    var dataObj = {
        buried_base_type:'worldcup_mission_click_points',
        worldcup_click_event:clickcolumn
        
    }
    objSite.buriedBuriedNewObj(dataObj);
})
// 埋点方法
objSite.buriedBuriedNewObj = function( data){
    data['view_url'] = window.location.href;
    data['up_time'] = Math.floor(new Date().getTime() / 1000);
    $.ajax({
        type: 'POST',
        url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
        timeout: 10000,
        data: data,
        dataType: 'json',
        xhrFields: {
            withCredentials: true
        },
        success: function (result) {
            // callback(result);
        },
        complete: function () {}
    })
};

// 关闭充值之后打开的弹框
$('body').on('click','.js_eleven_alt_href',function(){
	parent.layer.closeAll();
})

$('body').on('click','.js_href_eleven_page',function(){
    parent.layer.closeAll();
	// $('.eleven-bullet-frame').hide();
})


// 202303-埋点-溜云库web端新增下载入口点击事件
$(function () {

    // 公共字段值
    var objpost = {
        up_time:Math.floor(new Date().getTime() / 1000) || 0,
        view_url:window.location.href || '',
        element_target_url:'',
        browser_version:navigator.userAgent || "",
        element_id:'',
        buried_base_type:'lyk_web_download'
    }

    // 埋点公共接口
    function postBuriedData(prarms) {
        $.ajax({
            url: objSite.getServiceUrl('/api/v1/buried/buriedNew'),
            type: 'post',
            data: prarms,
            xhrFields: {
                withCredentials: true
            },
            success: function (res) {}
        })
    }

    // 云渲染官网-下载-第一屏
    $(document).on('click', '.download-left-btn .download-btn-act', function () {
        objpost.element_id = "30";
        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 企业首页顶部导航
    $(document).on('click', '.download-client-btn', function () {
        objpost.element_id = "25";
        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 企业首页底部
    $(document).on('click', '.work-join-btn a', function () {
        objpost.element_id = "26";
        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 企业官网-后台管理-导航栏下载弹窗
    $(document).on('click', '.js_download_lyk_new', function () {
        objpost.element_id = "35";
        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 企业首页底部-周边服务
    $(document).on('click', '.peripheral-services a:first', function () {
        objpost.element_id = "27";
        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 企业官网-功能-第一屏  && 企业官网-后台管理-客户端功能-第一屏
    $(document).on('click', '.multi-banner .banner-download-btn', function () {

        if(window.location.href.indexOf('company')> -1){
            objpost.element_id = "29";
        }else{
            objpost.element_id = "28";
        }
        
        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 溜溜网-素材详情页-溜云库下载按钮 && 溜溜网-模型标签列表页-所有详情页-溜云库下载按钮
    $(document).on('click', '.pop-down-lyk a', function () {

        if(parent.window.location.href.indexOf('relation')> -1){
            objpost.element_id = "32";
        }else if(parent.window.location.href.indexOf('company/group')> -1){
            objpost.element_id = "35";
        }else{
            objpost.element_id = "31";
        }

        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 溜溜网-MAX脚本列表-所有下载按钮
    $(document).on('click', '.information-icon a', function () {
        objpost.element_id = "15";
        objpost.element_target_url = $(this).attr("href") || '';
        postBuriedData(objpost);
    });

    // 全景贵族用户转化弹窗活动111
    if(!$.cookie("isTimes") && objSite.isLogin()){
        var date = new Date();
        // date.setTime(date.getTime()+(60 * 1000))
        date.setTime(date.getTime()+(60 * 60 * 1000))
        $.cookie("isTimes",'1h',{expires: date,domain: '3d66.com',path: '/'});  //第二天0点失效        
        vrVipUser(0);
    }else if(!$.cookie("isMonth") && $.cookie("isVrOpen")){
        vrVipUser(1);
    }
    function vrVipUser(prmrs){
        var isUrlArr=['/vr/release/index','/vr/index/index','/vr/release/resList','/vr/appoin/index','/vr/release/authorInfo',objSite.getVrUrl('/')];
        var getUrl = window.location.href;
        isUrlArr.forEach(function(item){
            if(getUrl.indexOf(item) != -1){
                $.ajax({
                    url: objSite.getServiceUrl('/activity202304/vr_recharge/activityTrigger'),
                    type: 'post',
                    data: {type:prmrs},
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function (res) {
                        if(res.status == 1){
                            if(res.data.type == 1 && getUrl.indexOf('/vr/release/index') != -1){
                                vrOpenAct(3, ['484px', '513px'], 3);
                            }else if(res.data.type == 2){
                                vrOpenAct(4, ['500px', '460px'], 1);
                            }else if(res.data.type == 3){
                                vrOpenAct(2, ['561px', '558px'], 2);
                            }else if(res.data.type == 4){
                                if(!$.cookie("vrType1")){
                                    vrOpenAct(1, ['518px', '557px'], 4);
                                }
                            }
                        }else{
                            layer.msg(res.msg);
                        }
                    }
                });
            }
        })
    };
    function vrOpenAct(type, area, point){
        layer.open({
            type: 2,
            closeBtn: 1,
            title: '',
            skin: 'layer-nobg', //加上边框
            area: area, //宽高
            content: objSite.getServiceUrl('/activity202304/vr_recharge/index?type='+type+'&point='+point),
            success: function (layero, index) {
                if(type == 1){
                    $.cookie("vrType1",'ok',{expires: 7,domain: '3d66.com',path: '/'});
                }else if(type == 3){
                    // 全景贵族用户转化弹窗活动
                    if(!$.cookie("isMonth")){
                        $.cookie("isMonth",'month',{domain: '3d66.com',path: '/'});  //30天失效
                        $.removeCookie("isVrOpen")
                    }
                }
            }
        });
    }

});
